Class: Pageflow::AdditionalHeaders
- Inherits:
-
Object
- Object
- Pageflow::AdditionalHeaders
- Defined in:
- lib/pageflow/additional_headers.rb
Overview
Register additional response headers for published entries.
Instance Method Summary collapse
- #for(entry, request) ⇒ Object private
-
#initialize ⇒ AdditionalHeaders
constructor
private
A new instance of AdditionalHeaders.
-
#register(headers) ⇒ Object
Either a hash of name values pair or a callable taking a PublishedEntry record and an ActionDispatch::Request object and returns a hash.
Constructor Details
#initialize ⇒ AdditionalHeaders
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of AdditionalHeaders.
5 6 7 |
# File 'lib/pageflow/additional_headers.rb', line 5 def initialize @headers = [] end |
Instance Method Details
#for(entry, request) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
17 18 19 20 21 22 23 24 25 |
# File 'lib/pageflow/additional_headers.rb', line 17 def for(entry, request) @headers.map { |headers| if headers.respond_to?(:call) headers.call(entry, request) else headers end }.reduce({}, :merge) end |
#register(headers) ⇒ Object
Either a hash of name values pair or a callable taking a PublishedEntry record and an ActionDispatch::Request object and returns a hash.
12 13 14 |
# File 'lib/pageflow/additional_headers.rb', line 12 def register(headers) @headers << headers end |