Class: ActionController::MimeResponds::Collector
- Inherits:
-
Object
- Object
- ActionController::MimeResponds::Collector
- Includes:
- AbstractController::Collector
- Defined in:
- actionpack/lib/action_controller/metal/mime_responds.rb
Overview
:nodoc:
Instance Attribute Summary (collapse)
-
- (Object) order
Returns the value of attribute order.
Instance Method Summary (collapse)
- - (Object) any(*args, &block) (also: #all)
- - (Object) custom(mime_type, &block)
-
- (Collector) initialize(&block)
constructor
A new instance of Collector.
- - (Object) response_for(mime)
Methods included from AbstractController::Collector
Constructor Details
- (Collector) initialize(&block)
A new instance of Collector
280 281 282 |
# File 'actionpack/lib/action_controller/metal/mime_responds.rb', line 280 def initialize(&block) @order, @responses, @default_response = [], {}, block end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class AbstractController::Collector
Instance Attribute Details
- (Object) order
Returns the value of attribute order
278 279 280 |
# File 'actionpack/lib/action_controller/metal/mime_responds.rb', line 278 def order @order end |
Instance Method Details
- (Object) any(*args, &block) Also known as: all
284 285 286 287 288 289 290 |
# File 'actionpack/lib/action_controller/metal/mime_responds.rb', line 284 def any(*args, &block) if args.any? args.each { |type| send(type, &block) } else custom(Mime::ALL, &block) end end |
- (Object) custom(mime_type, &block)
293 294 295 296 297 |
# File 'actionpack/lib/action_controller/metal/mime_responds.rb', line 293 def custom(mime_type, &block) mime_type = mime_type.is_a?(Mime::Type) ? mime_type : Mime::Type.lookup(mime_type.to_s) @order << mime_type @responses[mime_type] ||= block end |
- (Object) response_for(mime)
299 300 301 |
# File 'actionpack/lib/action_controller/metal/mime_responds.rb', line 299 def response_for(mime) @responses[mime] || @responses[Mime::ALL] || @default_response end |