Class: Reins::Controller::FormatCollector
- Inherits:
-
Object
- Object
- Reins::Controller::FormatCollector
- Defined in:
- lib/reins/controller.rb
Instance Attribute Summary collapse
-
#handlers ⇒ Object
readonly
Returns the value of attribute handlers.
-
#ordered_formats ⇒ Object
readonly
Returns the value of attribute ordered_formats.
Instance Method Summary collapse
- #html(&block) ⇒ Object
-
#initialize ⇒ FormatCollector
constructor
A new instance of FormatCollector.
- #json(&block) ⇒ Object
- #register(name, mime, block) ⇒ Object
Constructor Details
#initialize ⇒ FormatCollector
Returns a new instance of FormatCollector.
277 278 279 280 |
# File 'lib/reins/controller.rb', line 277 def initialize @ordered_formats = [] @handlers = {} end |
Instance Attribute Details
#handlers ⇒ Object (readonly)
Returns the value of attribute handlers.
275 276 277 |
# File 'lib/reins/controller.rb', line 275 def handlers @handlers end |
#ordered_formats ⇒ Object (readonly)
Returns the value of attribute ordered_formats.
275 276 277 |
# File 'lib/reins/controller.rb', line 275 def ordered_formats @ordered_formats end |
Instance Method Details
#html(&block) ⇒ Object
282 |
# File 'lib/reins/controller.rb', line 282 def html(&block) = register(:html, "text/html", block) |
#json(&block) ⇒ Object
283 |
# File 'lib/reins/controller.rb', line 283 def json(&block) = register(:json, "application/json", block) |
#register(name, mime, block) ⇒ Object
285 286 287 288 |
# File 'lib/reins/controller.rb', line 285 def register(name, mime, block) @ordered_formats << name @handlers[name] = { mime: mime, block: block } end |