Class: ActionController::MimeResponds::Collector
- Inherits:
-
Object
- Object
- ActionController::MimeResponds::Collector
- Includes:
- AbstractController::Collector
- Defined in:
- lib/action_controller/metal/mime_responds.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#format ⇒ Object
Returns the value of attribute format.
-
#order ⇒ Object
Returns the value of attribute order.
Instance Method Summary collapse
- #any(*args, &block) ⇒ Object (also: #all)
- #custom(mime_type, &block) ⇒ Object
-
#initialize(mimes) ⇒ Collector
constructor
A new instance of Collector.
- #negotiate_format(request) ⇒ Object
- #response ⇒ Object
Methods included from AbstractController::Collector
Constructor Details
#initialize(mimes) ⇒ Collector
Returns a new instance of Collector.
288 289 290 291 |
# File 'lib/action_controller/metal/mime_responds.rb', line 288 def initialize(mimes) @order, @responses = [], {} mimes.each { |mime| send(mime) } end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class AbstractController::Collector
Instance Attribute Details
#format ⇒ Object
Returns the value of attribute format.
286 287 288 |
# File 'lib/action_controller/metal/mime_responds.rb', line 286 def format @format end |
#order ⇒ Object
Returns the value of attribute order.
286 287 288 |
# File 'lib/action_controller/metal/mime_responds.rb', line 286 def order @order end |
Instance Method Details
#any(*args, &block) ⇒ Object Also known as: all
293 294 295 296 297 298 299 |
# File 'lib/action_controller/metal/mime_responds.rb', line 293 def any(*args, &block) if args.any? args.each { |type| send(type, &block) } else custom(Mime::ALL, &block) end end |
#custom(mime_type, &block) ⇒ Object
302 303 304 305 306 |
# File 'lib/action_controller/metal/mime_responds.rb', line 302 def custom(mime_type, &block) mime_type = Mime::Type.lookup(mime_type.to_s) unless mime_type.is_a?(Mime::Type) @order << mime_type @responses[mime_type] ||= block end |
#negotiate_format(request) ⇒ Object
312 313 314 |
# File 'lib/action_controller/metal/mime_responds.rb', line 312 def negotiate_format(request) @format = request.negotiate_mime(order) end |