Class: Restful::ApiModel::Map
- Inherits:
-
Object
- Object
- Restful::ApiModel::Map
- Defined in:
- lib/restful/apimodel/map.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#type ⇒ Object
Returns the value of attribute type.
-
#values ⇒ Object
Returns the value of attribute values.
Instance Method Summary collapse
- #collections ⇒ Object
-
#deserialize_from(type) ⇒ Object
invoke deserialization.
-
#initialize(name) ⇒ Map
constructor
A new instance of Map.
- #links ⇒ Object
-
#serialize(type) ⇒ Object
invoke serialization.
- #simple_attributes ⇒ Object
Constructor Details
#initialize(name) ⇒ Map
9 10 11 12 13 |
# File 'lib/restful/apimodel/map.rb', line 9 def initialize(name) self.name = name self.type = :hash self.values = [] end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/restful/apimodel/map.rb', line 7 def name @name end |
#type ⇒ Object
Returns the value of attribute type.
7 8 9 |
# File 'lib/restful/apimodel/map.rb', line 7 def type @type end |
#values ⇒ Object
Returns the value of attribute values.
7 8 9 |
# File 'lib/restful/apimodel/map.rb', line 7 def values @values end |
Instance Method Details
#collections ⇒ Object
23 24 25 |
# File 'lib/restful/apimodel/map.rb', line 23 def collections self.values.select { |attribute| attribute.type == :collection } end |
#deserialize_from(type) ⇒ Object
invoke deserialization
34 35 36 37 |
# File 'lib/restful/apimodel/map.rb', line 34 def deserialize_from(type) serializer = Restful::Serializers::Base.serializer(type) serializer.deserialize(self) end |
#links ⇒ Object
15 16 17 |
# File 'lib/restful/apimodel/map.rb', line 15 def links self.values.select { |attribute| attribute.type == :link } end |
#serialize(type) ⇒ Object
invoke serialization
28 29 30 31 |
# File 'lib/restful/apimodel/map.rb', line 28 def serialize(type) serializer = Restful::Serializers::Base.serializer(type) serializer.serialize(self) end |
#simple_attributes ⇒ Object
19 20 21 |
# File 'lib/restful/apimodel/map.rb', line 19 def simple_attributes self.values.select { |attribute| attribute.type == :simple_attribute } end |