module Roda::RodaPlugins::DefaultHeaders::ClassMethods

  1. lib/roda/plugins/default_headers.rb

Methods

Public Instance

  1. default_headers
  2. freeze

Public Instance methods

default_headers()

The default response headers to use for the current class.

[show source]
   # File lib/roda/plugins/default_headers.rb
31 def default_headers
32   opts[:default_headers]
33 end
freeze()

Optimize the response class set_default_headers method if it hasn’t been overridden and all default headers are strings.

[show source]
   # File lib/roda/plugins/default_headers.rb
37         def freeze
38           if (headers = opts[:default_headers]).all?{|k, v| k.is_a?(String) && v.is_a?(String)} &&
39              (self::RodaResponse.instance_method(:set_default_headers).owner == Base::ResponseMethods)
40             self::RodaResponse.class_eval(<<-END, __FILE__, __LINE__+1)
41               private
42 
43               def set_default_headers
44                 h = @headers
45                 #{headers.map{|k,v| "h[#{k.inspect}] ||= #{v.inspect}"}.join('; ')}
46               end
47             END
48           end
49 
50           super
51         end