Module: Rango::FormatMixin::ClassMethods

Defined in:
lib/rango/mixins/rendering.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#format(format = nil, &block) ⇒ Object

format(:json) do |object|

object.to_json

end



49
50
51
52
53
54
55
# File 'lib/rango/mixins/rendering.rb', line 49

def format(format = nil, &block)
  if format
    self.formats[:format] = block
  else
    self.formats.default_proc = block
  end
end

Instance Method Details

#formatsObject



40
41
42
43
44
# File 'lib/rango/mixins/rendering.rb', line 40

def formats
  @formats ||= Hash.new do |hash, format|
    raise BadRequest, "Unsupported format"
  end
end