Class: SimpleObjectSerialization::Attributes
- Inherits:
-
Object
- Object
- SimpleObjectSerialization::Attributes
- Defined in:
- lib/simple_object_serialization/attributes.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
Instance Method Summary collapse
- #hash_for(serializer) ⇒ Object
-
#initialize ⇒ Attributes
constructor
A new instance of Attributes.
- #push(attribute) ⇒ Object
Constructor Details
#initialize ⇒ Attributes
Returns a new instance of Attributes.
7 8 9 |
# File 'lib/simple_object_serialization/attributes.rb', line 7 def initialize @attributes = [] end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
5 6 7 |
# File 'lib/simple_object_serialization/attributes.rb', line 5 def attributes @attributes end |
Instance Method Details
#hash_for(serializer) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/simple_object_serialization/attributes.rb', line 15 def hash_for(serializer) {}.tap do |hash| attributes.each do |attribute| next if attribute.skip_for?(serializer) hash[attribute.name] = attribute.value_for(serializer) end end end |
#push(attribute) ⇒ Object
11 12 13 |
# File 'lib/simple_object_serialization/attributes.rb', line 11 def push(attribute) attributes.push(attribute) end |