Class: Arrest::NestedAttribute

Inherits:
Attribute show all
Defined in:
lib/arrest/attributes/nested_attribute.rb

Direct Known Subclasses

PolymorphicAttribute

Instance Attribute Summary

Attributes inherited from Attribute

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

Instance Method Summary collapse

Methods inherited from Attribute

#dirty?, #mutable?, #read_only?

Constructor Details

#initialize(name, clazz, options) ⇒ NestedAttribute

Returns a new instance of NestedAttribute.



3
4
5
# File 'lib/arrest/attributes/nested_attribute.rb', line 3

def initialize name, clazz, options
  super name, clazz, options
end

Instance Method Details

#from_hash(parent, value) ⇒ Object



7
8
9
10
# File 'lib/arrest/attributes/nested_attribute.rb', line 7

def from_hash(parent, value)
  return nil unless value != nil
  @clazz.new(parent, value)
end

#to_hash(val) ⇒ Object



12
13
14
15
# File 'lib/arrest/attributes/nested_attribute.rb', line 12

def to_hash val
  return nil unless val!= nil
  val.to_hash
end