Class: ActionController::MimeResponds::Responder
- Inherits:
-
Object
- Object
- ActionController::MimeResponds::Responder
- Defined in:
- lib/vendor/plugins/inherited_resources/lib/inherited_resources/legacy/respond_to.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#order ⇒ Object
readonly
Returns the value of attribute order.
Instance Method Summary collapse
- #any(*args, &block) ⇒ Object (also: #all)
- #custom(mime_type, &block) ⇒ Object
- #negotiate_mime ⇒ Object
- #response_for(mime) ⇒ Object
Instance Attribute Details
#order ⇒ Object (readonly)
Returns the value of attribute order.
117 118 119 |
# File 'lib/vendor/plugins/inherited_resources/lib/inherited_resources/legacy/respond_to.rb', line 117 def order @order end |
Instance Method Details
#any(*args, &block) ⇒ Object Also known as: all
119 120 121 122 123 124 125 |
# File 'lib/vendor/plugins/inherited_resources/lib/inherited_resources/legacy/respond_to.rb', line 119 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
128 129 130 131 132 |
# File 'lib/vendor/plugins/inherited_resources/lib/inherited_resources/legacy/respond_to.rb', line 128 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 |
#negotiate_mime ⇒ Object
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/vendor/plugins/inherited_resources/lib/inherited_resources/legacy/respond_to.rb', line 138 def negotiate_mime @mime_type_priority.each do |priority| if priority == Mime::ALL return @order.first elsif @order.include?(priority) return priority end end if @order.include?(Mime::ALL) return Mime::SET.first if @mime_type_priority.first == Mime::ALL return @mime_type_priority.first end nil end |
#response_for(mime) ⇒ Object
134 135 136 |
# File 'lib/vendor/plugins/inherited_resources/lib/inherited_resources/legacy/respond_to.rb', line 134 def response_for(mime) @responses[mime] || @responses[Mime::ALL] end |