Class: Cadooz::Immutable::Attributes

Inherits:
Object
  • Object
show all
Includes:
Mixins
Defined in:
lib/cadooz/models/immutable/attributes.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#attributeObject (readonly)

Returns the value of attribute attribute.



4
5
6
# File 'lib/cadooz/models/immutable/attributes.rb', line 4

def attribute
  @attribute
end

#valuesObject (readonly)

Returns the value of attribute values.



4
5
6
# File 'lib/cadooz/models/immutable/attributes.rb', line 4

def values
  @values
end