Module: Strelka::HTTPResponse::Presenters
- Defined in:
- lib/strelka/httpresponse/presenters.rb
Overview
Hypermedia presentation logic for Strelka HTTP responses
Instance Attribute Summary collapse
-
#presenter ⇒ Object
The presenter to use when negotiating the response.
Instance Method Summary collapse
-
#[] ⇒ Object
Added so we can pass the response object to the presenters as the ‘env`.
-
#initialize ⇒ Object
Initialize some instance variables when a new response is created.
-
#present(entity, **options) ⇒ Object
Set the entity that should be rendered to form the response body.
Instance Attribute Details
#presenter ⇒ Object
The presenter to use when negotiating the response
25 26 27 |
# File 'lib/strelka/httpresponse/presenters.rb', line 25 def presenter @presenter end |
Instance Method Details
#[] ⇒ Object
Added so we can pass the response object to the presenters as the ‘env`.
29 30 31 |
# File 'lib/strelka/httpresponse/presenters.rb', line 29 def []( * ) # :nodoc: return nil end |
#initialize ⇒ Object
Initialize some instance variables when a new response is created.
13 14 15 16 |
# File 'lib/strelka/httpresponse/presenters.rb', line 13 def initialize( * ) @presenter = nil super end |
#present(entity, **options) ⇒ Object
Set the entity that should be rendered to form the response body.
35 36 37 38 39 40 41 42 |
# File 'lib/strelka/httpresponse/presenters.rb', line 35 def present( entity, ** ) Yaks::Format.all.each do |format| self.for( format.media_type ) do opts = .merge( format: format.format_name, env: self ) self.presenter.call( entity, opts ) end end end |