Class: Arrest::NestedAttribute
- Defined in:
- lib/arrest/attributes/nested_attribute.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Attribute
#clazz, #json_name, #name, #read_only
Instance Method Summary collapse
- #from_hash(parent, value) ⇒ Object
-
#initialize(name, read_only, clazz) ⇒ NestedAttribute
constructor
A new instance of NestedAttribute.
- #to_hash(val) ⇒ Object
Constructor Details
#initialize(name, read_only, clazz) ⇒ NestedAttribute
Returns a new instance of NestedAttribute.
3 4 5 |
# File 'lib/arrest/attributes/nested_attribute.rb', line 3 def initialize name, read_only, clazz super name, read_only, clazz 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 |