Class: Prawnto::TemplateHandler::CompileSupport
- Inherits:
-
Object
- Object
- Prawnto::TemplateHandler::CompileSupport
- Defined in:
- lib/prawnto/template_handler/compile_support.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#ie_request? ⇒ Boolean
TODO: kept around from railspdf– maybe not needed anymore? should check.
-
#initialize(controller) ⇒ CompileSupport
constructor
A new instance of CompileSupport.
- #pull_options ⇒ Object
-
#set_cache_control ⇒ Object
TODO: kept around from railspdf– maybe not needed anymore? should check.
- #set_content_type ⇒ Object
- #set_disposition ⇒ Object
- #set_headers ⇒ Object
-
#set_pragma ⇒ Object
TODO: kept around from railspdf– maybe not needed anymore? should check.
-
#ssl_request? ⇒ Boolean
added to make ie happy with ssl pdf’s (per naisayer).
Constructor Details
#initialize(controller) ⇒ CompileSupport
Returns a new instance of CompileSupport.
6 7 8 9 10 |
# File 'lib/prawnto/template_handler/compile_support.rb', line 6 def initialize(controller) @controller = controller @options = set_headers end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'lib/prawnto/template_handler/compile_support.rb', line 4 def @options end |
Instance Method Details
#ie_request? ⇒ Boolean
TODO: kept around from railspdf– maybe not needed anymore? should check.
24 25 26 27 |
# File 'lib/prawnto/template_handler/compile_support.rb', line 24 def ie_request? return @ie_request if instance_variable_defined?(:@ie_request) @ie_request = @controller.request.env['HTTP_USER_AGENT'] =~ /msie/i end |
#pull_options ⇒ Object
12 13 14 |
# File 'lib/prawnto/template_handler/compile_support.rb', line 12 def @controller.send :compute_prawnto_options || {} end |
#set_cache_control ⇒ Object
TODO: kept around from railspdf– maybe not needed anymore? should check.
46 47 48 49 50 51 52 |
# File 'lib/prawnto/template_handler/compile_support.rb', line 46 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 |
#set_content_type ⇒ Object
54 55 56 |
# File 'lib/prawnto/template_handler/compile_support.rb', line 54 def set_content_type @controller.response.content_type ||= Mime::PDF end |
#set_disposition ⇒ Object
58 59 60 61 62 |
# File 'lib/prawnto/template_handler/compile_support.rb', line 58 def set_disposition inline = [:inline] ? 'inline' : 'attachment' filename = [:filename] ? "filename=#{[:filename]}" : nil @controller.headers["Content-Disposition"] = [inline,filename].compact.join(';') end |
#set_headers ⇒ Object
16 17 18 19 20 21 |
# File 'lib/prawnto/template_handler/compile_support.rb', line 16 def set_headers set_pragma set_cache_control set_content_type set_disposition end |
#set_pragma ⇒ Object
TODO: kept around from railspdf– maybe not needed anymore? should check.
37 38 39 40 41 42 43 |
# File 'lib/prawnto/template_handler/compile_support.rb', line 37 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 |
#ssl_request? ⇒ Boolean
added to make ie happy with ssl pdf’s (per naisayer)
30 31 32 33 34 |
# File 'lib/prawnto/template_handler/compile_support.rb', line 30 def ssl_request? return @ssl_request if instance_variable_defined?(:@ssl_request) protocol = @controller.request.env['SERVER_PROTOCOL'] @ssl_request = protocol && protocol.downcase == "https" end |