Module: Merb::ResponderMixin::ClassMethods

Defined in:
merb-core/lib/merb-core/controller/mixins/responder.rb

Instance Method Summary collapse

Instance Method Details

#clear_providesArray

Clear the list of provides.

Returns:

  • (Array)

    An empty Array.



171
172
173
# File 'merb-core/lib/merb-core/controller/mixins/responder.rb', line 171

def clear_provides
  self.class_provided_formats.clear
end

#does_not_provide(*formats) ⇒ Array<Symbol>

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<Symbol>)

    List of formats that remain after removing the ones not to provide.



162
163
164
# File 'merb-core/lib/merb-core/controller/mixins/responder.rb', line 162

def does_not_provide(*formats)
  self.class_provided_formats -= formats
end

#only_provides(*formats) ⇒ Array<Symbol>

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<Symbol>)

    List of formats passed in.



148
149
150
151
# File 'merb-core/lib/merb-core/controller/mixins/responder.rb', line 148

def only_provides(*formats)
  clear_provides
  provides(*formats)
end

#provides(*formats) ⇒ Array<Symbol>

Adds symbols representing formats to the controller's default list of providedformats. 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 method as needed.

Examples:

provides :html, :xml

Parameters:

  • *formats (Symbol)

    A list of mime-types that the controller should provide.

Returns:

  • (Array<Symbol>)

    List of formats passed in.



136
137
138
# File 'merb-core/lib/merb-core/controller/mixins/responder.rb', line 136

def provides(*formats)
  self.class_provided_formats |= formats
end

#reset_providesArray<Symbol>

Reset the list of provides to include only :html.

Returns:

  • (Array<Symbol>)

    [:html].



180
181
182
# File 'merb-core/lib/merb-core/controller/mixins/responder.rb', line 180

def reset_provides
  only_provides(:html)
end