Class: Etna::Clients::Magma::Attributes

Inherits:
Object
  • Object
show all
Defined in:
lib/etna/clients/magma/models.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw = {}) ⇒ Attributes

Returns a new instance of Attributes.



431
432
433
# File 'lib/etna/clients/magma/models.rb', line 431

def initialize(raw = {})
  @raw = raw
end

Instance Attribute Details

#rawObject (readonly)

Returns the value of attribute raw.



429
430
431
# File 'lib/etna/clients/magma/models.rb', line 429

def raw
  @raw
end

Instance Method Details

#allObject



448
449
450
# File 'lib/etna/clients/magma/models.rb', line 448

def all
  raw.values.map { |r| Attribute.new(r) }
end

#attribute(attribute_key) ⇒ Object



439
440
441
442
# File 'lib/etna/clients/magma/models.rb', line 439

def attribute(attribute_key)
  return nil unless raw.include?(attribute_key.to_s)
  Attribute.new(raw[attribute_key.to_s])
end

#attribute_keysObject



435
436
437
# File 'lib/etna/clients/magma/models.rb', line 435

def attribute_keys
  raw.keys
end

#build_attribute(key) ⇒ Object



444
445
446
# File 'lib/etna/clients/magma/models.rb', line 444

def build_attribute(key)
  Attribute.new(raw[key] ||= {})
end