Class: Hypa::AttributeSet

Inherits:
Object
  • Object
show all
Defined in:
lib/hypa.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ AttributeSet

Returns a new instance of AttributeSet.



22
23
24
25
# File 'lib/hypa.rb', line 22

def initialize(&block)
  @attributes = []
  block.call(self) if block_given?
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



20
21
22
# File 'lib/hypa.rb', line 20

def attributes
  @attributes
end

Instance Method Details

#attribute(name, properties = {}) ⇒ Object



27
28
29
# File 'lib/hypa.rb', line 27

def attribute(name, properties = {})
  @attributes << Attribute.new(properties.merge(name: name))
end

#to_hashObject

def set(name, &block)

@sets[name] << AttributeSet.new(&block)

end



35
36
37
# File 'lib/hypa.rb', line 35

def to_hash
  @attributes.map { |a| a.to_hash }
end