Module: Roda::RodaPlugins::DefaultHeaders::ClassMethods
- Defined in:
- lib/roda/plugins/default_headers.rb
Instance Method Summary collapse
-
#default_headers ⇒ Object
The default response headers to use for the current class.
-
#freeze ⇒ Object
Optimize the response class set_default_headers method if it hasn’t been overridden and all default headers are strings.
Instance Method Details
#default_headers ⇒ Object
The default response headers to use for the current class.
31 32 33 |
# File 'lib/roda/plugins/default_headers.rb', line 31 def default_headers opts[:default_headers] end |
#freeze ⇒ Object
Optimize the response class set_default_headers method if it hasn’t been overridden and all default headers are strings.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/roda/plugins/default_headers.rb', line 37 def freeze if (headers = opts[:default_headers]).all?{|k, v| k.is_a?(String) && v.is_a?(String)} && (self::RodaResponse.instance_method(:set_default_headers).owner == Base::ResponseMethods) self::RodaResponse.class_eval(<<-END, __FILE__, __LINE__+1) private def set_default_headers h = @headers #{headers.map{|k,v| "h[#{k.inspect}] ||= #{v.inspect}"}.join('; ')} end END end super end |