Class: ActiveInteractor::Context::AttributeSet
- Inherits:
-
Object
- Object
- ActiveInteractor::Context::AttributeSet
- Defined in:
- lib/active_interactor/context/attribute_set.rb
Instance Method Summary collapse
- #add(*attribute_args) ⇒ Object
- #attribute_names ⇒ Object
- #attributes ⇒ Object
- #find(attribute_name) ⇒ Object
-
#initialize(*attributes) ⇒ AttributeSet
constructor
A new instance of AttributeSet.
- #merge(attributes) ⇒ Object
Constructor Details
#initialize(*attributes) ⇒ AttributeSet
Returns a new instance of AttributeSet.
6 7 8 9 |
# File 'lib/active_interactor/context/attribute_set.rb', line 6 def initialize(*attributes) @set = {} attributes.each { |attribute| @set[attribute.name] = attribute } end |
Instance Method Details
#add(*attribute_args) ⇒ Object
11 12 13 14 15 |
# File 'lib/active_interactor/context/attribute_set.rb', line 11 def add(*attribute_args) = attribute_args. attribute = Attribute.new(*attribute_args, **) @set[attribute.name] = attribute end |
#attribute_names ⇒ Object
17 18 19 |
# File 'lib/active_interactor/context/attribute_set.rb', line 17 def attribute_names @set.keys end |
#attributes ⇒ Object
21 22 23 |
# File 'lib/active_interactor/context/attribute_set.rb', line 21 def attributes @set.values end |
#find(attribute_name) ⇒ Object
25 26 27 |
# File 'lib/active_interactor/context/attribute_set.rb', line 25 def find(attribute_name) @set[attribute_name.to_sym] end |
#merge(attributes) ⇒ Object
29 30 31 |
# File 'lib/active_interactor/context/attribute_set.rb', line 29 def merge(attributes) attributes.each { |attribute| @set[attribute.name] = attribute } end |