Class: Arrest::PolymorphicAttribute

Inherits:
NestedAttribute show all
Defined in:
lib/arrest/attributes/polymorphic_attribute.rb

Instance Attribute Summary

Attributes inherited from Attribute

#actions, #clazz, #dirty, #json_name, #name

Instance Method Summary collapse

Methods inherited from NestedAttribute

#to_hash

Methods inherited from Attribute

#dirty?, #mutable?, #read_only?, #to_hash

Constructor Details

#initialize(name, actions) ⇒ PolymorphicAttribute

Returns a new instance of PolymorphicAttribute.



18
19
20
# File 'lib/arrest/attributes/polymorphic_attribute.rb', line 18

def initialize name, actions
  super name, Ref, actions
end

Instance Method Details

#from_hash(parent, value) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/arrest/attributes/polymorphic_attribute.rb', line 22

def from_hash(parent, value)
  return nil unless value != nil
  if value.is_a? Hash
    @clazz.new(value)
  else
    @clazz.new(value.to_hash)
  end
end