Class: ActionController::MimeResponds::Collector::VariantCollector
Do not use. This class is for internal use only.
Relationships & Source Files | |
Inherits: | Object |
Defined in: | actionpack/lib/action_controller/metal/mime_responds.rb |
Class Method Summary
- .new(variant = nil) ⇒ VariantCollector constructor
Instance Method Summary
-
#all(*args, &block)
Alias for #any.
- #any(*args, &block) (also: #all)
- #method_missing(name, &block)
- #variant
- #variant_key private
Constructor Details
.new(variant = nil) ⇒ VariantCollector
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, &block)
[ GitHub ]# File 'actionpack/lib/action_controller/metal/mime_responds.rb', line 318
def method_missing(name, *, &block) @variants[name] = block if block_given? end
Instance Method Details
#all(*args, &block)
Alias for #any.
# File 'actionpack/lib/action_controller/metal/mime_responds.rb', line 316
alias :all :any
#any(*args, &block) Also known as: #all
[ GitHub ]# File 'actionpack/lib/action_controller/metal/mime_responds.rb', line 307
def any(*args, &block) if block_given? if args.any? && args.none? { |a| a == @variant } args.each { |v| @variants[v] = block } else @variants[:any] = block end end end
#variant
[ GitHub ]# File 'actionpack/lib/action_controller/metal/mime_responds.rb', line 322
def variant if @variant.empty? @variants[:none] || @variants[:any] else @variants[variant_key] end end