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, #dirty, #json_name, #name

Instance Method Summary collapse

Methods inherited from Attribute

#clazz, #clazz=, #dirty?, #dirty_sensitive?, #mutable?, #read_only?

Constructor Details

#initialize(name, class_name, options) ⇒ NestedAttribute

Returns a new instance of NestedAttribute.



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

def initialize name, class_name, options
  super name, class_name, options
end

Instance Method Details

#from_hash(parent, value) ⇒ Object



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

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

#to_hash(val) ⇒ Object



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

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