Module: Representable::Coercion

Defined in:
lib/representable/coercion.rb

Defined Under Namespace

Modules: ClassMethods Classes: Coercer

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object

separate coercion object doesn’t give us initializer and accessors in the represented object (with module representer)!



16
17
18
19
20
21
22
23
# File 'lib/representable/coercion.rb', line 16

def self.included(base)
  base.class_eval do
    extend ClassMethods
    # FIXME: use inheritable_attr when it's ready.
    representable_attrs.inheritable_array(:coercer_class) << Class.new(Coercer) unless representable_attrs.inheritable_array(:coercer_class).first
  end

end

Instance Method Details

#coercerObject



40
41
42
# File 'lib/representable/coercion.rb', line 40

def coercer
  @coercer ||= representable_attrs.inheritable_array(:coercer_class).first.new
end