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(owner, *attributes) ⇒ AttributeSet
constructor
A new instance of AttributeSet.
- #merge(attributes) ⇒ Object
Constructor Details
#initialize(owner, *attributes) ⇒ AttributeSet
Returns a new instance of AttributeSet.
6 7 8 9 10 |
# File 'lib/active_interactor/context/attribute_set.rb', line 6 def initialize(owner, *attributes) @owner = owner @set = {} attributes.each { |attribute| @set[attribute.name] = attribute } end |
Instance Method Details
#add(*attribute_args) ⇒ Object
12 13 14 15 16 |
# File 'lib/active_interactor/context/attribute_set.rb', line 12 def add(*attribute_args) = attribute_args. attribute = Attribute.new(@owner, *attribute_args, **) @set[attribute.name] = attribute end |
#attribute_names ⇒ Object
18 19 20 |
# File 'lib/active_interactor/context/attribute_set.rb', line 18 def attribute_names @set.keys end |
#attributes ⇒ Object
22 23 24 |
# File 'lib/active_interactor/context/attribute_set.rb', line 22 def attributes @set.values end |
#find(attribute_name) ⇒ Object
26 27 28 |
# File 'lib/active_interactor/context/attribute_set.rb', line 26 def find(attribute_name) @set[attribute_name.to_sym] end |
#merge(attributes) ⇒ Object
30 31 32 |
# File 'lib/active_interactor/context/attribute_set.rb', line 30 def merge(attributes) attributes.each { |attribute| @set[attribute.name] = attribute } end |