Class: Prawnto::TemplateHandler::CompileSupport
- Inherits:
-
Object
- Object
- Prawnto::TemplateHandler::CompileSupport
- Extended by:
- ActiveSupport::Memoizable
- Defined in:
- lib/prawnto/template_handler/compile_support.rb
Instance Attribute Summary (collapse)
-
- (Object) options
readonly
Returns the value of attribute options.
Instance Method Summary (collapse)
-
- (Boolean) ie_request?
TODO: kept around from railspdf-- maybe not needed anymore? should check.
-
- (CompileSupport) initialize(controller)
constructor
A new instance of CompileSupport.
- - (Object) pull_options
-
- (Object) set_cache_control
TODO: kept around from railspdf-- maybe not needed anymore? should check.
- - (Object) set_content_type
- - (Object) set_disposition
- - (Object) set_headers
-
- (Object) set_pragma
TODO: kept around from railspdf-- maybe not needed anymore? should check.
-
- (Boolean) ssl_request?
added to make ie happy with ssl pdf's (per naisayer).
Constructor Details
- (CompileSupport) initialize(controller)
A new instance of CompileSupport
9 10 11 12 13 |
# File 'lib/prawnto/template_handler/compile_support.rb', line 9 def initialize(controller) @controller = controller @options = set_headers end |
Instance Attribute Details
- (Object) options (readonly)
Returns the value of attribute options
7 8 9 |
# File 'lib/prawnto/template_handler/compile_support.rb', line 7 def @options end |
Instance Method Details
- (Boolean) ie_request?
TODO: kept around from railspdf-- maybe not needed anymore? should check.
27 28 29 |
# File 'lib/prawnto/template_handler/compile_support.rb', line 27 def ie_request? @controller.request.env['HTTP_USER_AGENT'] =~ /msie/i end |
- (Object) pull_options
15 16 17 |
# File 'lib/prawnto/template_handler/compile_support.rb', line 15 def @controller.send :compute_prawnto_options || {} end |
- (Object) set_cache_control
TODO: kept around from railspdf-- maybe not needed anymore? should check.
48 49 50 51 52 53 54 |
# File 'lib/prawnto/template_handler/compile_support.rb', line 48 def set_cache_control if ssl_request? && ie_request? @controller.headers['Cache-Control'] = 'maxage=1' # added to make ie ssl pdfs work (per naisayer) else @controller.headers['Cache-Control'] ||= ie_request? ? 'no-cache, must-revalidate' : '' end end |
- (Object) set_content_type
56 57 58 |
# File 'lib/prawnto/template_handler/compile_support.rb', line 56 def set_content_type @controller.response.content_type ||= Mime::PDF end |
- (Object) set_disposition
60 61 62 63 64 |
# File 'lib/prawnto/template_handler/compile_support.rb', line 60 def set_disposition inline = [:inline] ? 'inline' : 'attachment' filename = [:filename] ? "filename=#{[:filename]}" : nil @controller.headers["Content-Disposition"] = [inline,filename].compact.join(';') end |
- (Object) set_headers
19 20 21 22 23 24 |
# File 'lib/prawnto/template_handler/compile_support.rb', line 19 def set_headers set_pragma set_cache_control set_content_type set_disposition end |
- (Object) set_pragma
TODO: kept around from railspdf-- maybe not needed anymore? should check.
39 40 41 42 43 44 45 |
# File 'lib/prawnto/template_handler/compile_support.rb', line 39 def set_pragma if ssl_request? && ie_request? @controller.headers['Pragma'] = 'public' # added to make ie ssl pdfs work (per naisayer) else @controller.headers['Pragma'] ||= ie_request? ? 'no-cache' : '' end end |
- (Boolean) ssl_request?
added to make ie happy with ssl pdf's (per naisayer)
33 34 35 |
# File 'lib/prawnto/template_handler/compile_support.rb', line 33 def ssl_request? @controller.request.env['SERVER_PROTOCOL'].downcase == "https" end |