Module: Merb::ResponderMixin::ClassMethods
- Defined in:
- lib/merb-core/controller/mixins/responder.rb
Instance Method Summary collapse
-
#clear_provides ⇒ Object
Clear the list of provides.
-
#does_not_provide(*formats) ⇒ Object
This class should not provide any of this list of formats, despite any.
-
#only_provides(*formats) ⇒ Object
This class should only provide the formats listed here, despite any other definitions previously or in superclasses.
-
#provides(*formats) ⇒ Object
Adds symbols representing formats to the controller’s default list of provided_formats.
-
#reset_provides ⇒ Object
Reset the list of provides to include only :html.
Instance Method Details
#clear_provides ⇒ Object
Clear the list of provides.
Returns
- Array
-
An empty Array.
175 176 177 |
# File 'lib/merb-core/controller/mixins/responder.rb', line 175 def clear_provides self.class_provided_formats.clear end |
#does_not_provide(*formats) ⇒ Object
This class should not provide any of this list of formats, despite any. other definitions previously or in superclasses.
Parameters
- *formats<Symbol>
-
Registered mime-types.
Returns
- Array
-
List of formats that remain after removing the ones not to provide.
167 168 169 |
# File 'lib/merb-core/controller/mixins/responder.rb', line 167 def does_not_provide(*formats) self.class_provided_formats -= formats end |
#only_provides(*formats) ⇒ Object
This class should only provide the formats listed here, despite any other definitions previously or in superclasses.
Parameters
- *formats<Symbol>
-
Registered mime-types.
Returns
- Array
-
List of formats passed in.
150 151 152 153 |
# File 'lib/merb-core/controller/mixins/responder.rb', line 150 def only_provides(*formats) clear_provides provides(*formats) end |
#provides(*formats) ⇒ Object
Adds symbols representing formats to the controller’s default list of provided_formats. These will apply to every action in the controller, unless modified in the action. If the last argument is a Hash or an Array, these are regarded as arguments to pass to the to_<mime_type> method as needed.
Parameters
- *formats<Symbol>
-
A list of mime-types that the controller should provide.
Returns
- Array
-
List of formats passed in.
Examples
provides :html, :xml
133 134 135 136 137 |
# File 'lib/merb-core/controller/mixins/responder.rb', line 133 def provides(*formats) formats.each do |fmt| self.class_provided_formats << fmt unless class_provided_formats.include?(fmt) end end |