Class: Cadooz::Immutable::Attributes
- Inherits:
-
Object
- Object
- Cadooz::Immutable::Attributes
- Includes:
- Mixins
- Defined in:
- lib/cadooz/models/immutable/attributes.rb
Instance Attribute Summary collapse
-
#attribute ⇒ Object
readonly
Returns the value of attribute attribute.
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Instance Method Summary collapse
-
#initialize(open_struct) ⇒ Attributes
constructor
A new instance of Attributes.
Methods included from Mixins
#cadooz_class, #default_value_for_nil, #instance_variables_empty?, #serialize
Constructor Details
#initialize(open_struct) ⇒ Attributes
Returns a new instance of Attributes.
6 7 8 9 10 11 12 13 14 |
# File 'lib/cadooz/models/immutable/attributes.rb', line 6 def initialize(open_struct) @attribute = open_struct&.attribute @values = open_struct&.values &.map_entries &.elements &.inject({}) { |hash, element| hash.merge(element.key.to_sym => element.value) } self.freeze end |
Instance Attribute Details
#attribute ⇒ Object (readonly)
Returns the value of attribute attribute.
4 5 6 |
# File 'lib/cadooz/models/immutable/attributes.rb', line 4 def attribute @attribute end |
#values ⇒ Object (readonly)
Returns the value of attribute values.
4 5 6 |
# File 'lib/cadooz/models/immutable/attributes.rb', line 4 def values @values end |