Class: Protos::Attributes
- Inherits:
-
Object
- Object
- Protos::Attributes
- Defined in:
- lib/protos/attributes.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize(attrs = {}, **kwargs) ⇒ Attributes
constructor
DOCS: A class that represents the attributes of a component.
- #merge(hash) ⇒ Object
-
#to_hash ⇒ Object
Allows for the use of the ‘**` operator to pass the attributes to a method.
Constructor Details
#initialize(attrs = {}, **kwargs) ⇒ Attributes
DOCS: A class that represents the attributes of a component. This would be all html options except for ‘class` and `theme`.
8 9 10 |
# File 'lib/protos/attributes.rb', line 8 def initialize(attrs = {}, **kwargs) @attrs = attrs.merge!(kwargs) end |
Instance Method Details
#[](key) ⇒ Object
12 13 14 |
# File 'lib/protos/attributes.rb', line 12 def [](key) @attrs[key] end |
#merge(hash) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/protos/attributes.rb', line 16 def merge(hash) return self unless hash @attrs = mix(@attrs, hash) self end |
#to_hash ⇒ Object
Allows for the use of the ‘**` operator to pass the attributes to a method.
25 26 27 |
# File 'lib/protos/attributes.rb', line 25 def to_hash @attrs end |