Class: Perpetuity::AttributeSet

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/perpetuity/attribute_set.rb

Instance Method Summary collapse

Constructor Details

#initialize(*attributes) ⇒ AttributeSet

Returns a new instance of AttributeSet.



5
6
7
8
9
10
# File 'lib/perpetuity/attribute_set.rb', line 5

def initialize *attributes
  @attributes = {}
  attributes.each do |attribute|
    self << attribute
  end
end

Instance Method Details

#<<(attribute) ⇒ Object



12
13
14
15
# File 'lib/perpetuity/attribute_set.rb', line 12

def << attribute
  @attributes[attribute.name] = attribute
  self
end

#[](name) ⇒ Object



17
18
19
# File 'lib/perpetuity/attribute_set.rb', line 17

def [] name
  @attributes[name]
end

#each(&block) ⇒ Object



21
22
23
# File 'lib/perpetuity/attribute_set.rb', line 21

def each &block
  @attributes.each_value(&block)
end