Module: Representable::Coercion::ClassMethods

Defined in:
lib/representable/coercion.rb

Instance Method Summary collapse

Instance Method Details

#property(name, options = {}, &block) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/representable/coercion.rb', line 29

def property(name, options={}, &block)
  super.tap do |definition|
    return definition unless type = options[:type]

    definition.merge!(render_filter: coercer = Coercer.new(type))
    definition.merge!(parse_filter: coercer)
  end
end