Class: Hypa::AttributeSet
- Inherits:
-
Object
- Object
- Hypa::AttributeSet
- Defined in:
- lib/hypa.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
Instance Method Summary collapse
- #attribute(name, properties = {}) ⇒ Object
-
#initialize(&block) ⇒ AttributeSet
constructor
A new instance of AttributeSet.
-
#to_hash ⇒ Object
def set(name, &block) @sets << AttributeSet.new(&block) end.
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
#attributes ⇒ Object (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_hash ⇒ Object
35 36 37 |
# File 'lib/hypa.rb', line 35 def to_hash @attributes.map { |a| a.to_hash } end |