Class: ActiveInteractor::Base
- Inherits:
-
Object
- Object
- ActiveInteractor::Base
- Defined in:
- lib/active_interactor/base.rb
Class Method Summary collapse
- .argument(name, type, description = nil, **options) ⇒ Object
- .perform(input_context = {}) ⇒ Object
- .returns(name, type, description = nil, **options) ⇒ Object
Instance Method Summary collapse
-
#initialize(input = {}) ⇒ Base
constructor
A new instance of Base.
- #perform ⇒ Object
- #rollback ⇒ Object
Constructor Details
#initialize(input = {}) ⇒ Base
Returns a new instance of Base.
29 30 31 32 |
# File 'lib/active_interactor/base.rb', line 29 def initialize(input = {}) @input = input.freeze @context = parse_input! end |
Class Method Details
.argument(name, type, description = nil, **options) ⇒ Object
6 7 8 |
# File 'lib/active_interactor/base.rb', line 6 def argument(name, type, description = nil, **) attributes[:arguments][name.to_sym] = { name: name, type: type, description: description }.merge() end |
.perform(input_context = {}) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/active_interactor/base.rb', line 10 def perform(input_context = {}) new(input_context).send(:exec_perform!) rescue Error => e e.result rescue StandardError => e Result.failure(errors: e.) end |
.returns(name, type, description = nil, **options) ⇒ Object
18 19 20 |
# File 'lib/active_interactor/base.rb', line 18 def returns(name, type, description = nil, **) attributes[:fields][name.to_sym] = { name: name, type: type, description: description }.merge() end |
Instance Method Details
#perform ⇒ Object
34 |
# File 'lib/active_interactor/base.rb', line 34 def perform; end |
#rollback ⇒ Object
35 |
# File 'lib/active_interactor/base.rb', line 35 def rollback; end |