Class: ActiveInteractor::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/active_interactor/base.rb

Class Method Summary collapse

Instance Method Summary collapse

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, **options)
  attributes[:arguments][name.to_sym] = { name: name, type: type, description: description }.merge(options)
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.message)
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, **options)
  attributes[:fields][name.to_sym] = { name: name, type: type, description: description }.merge(options)
end

Instance Method Details

#performObject



34
# File 'lib/active_interactor/base.rb', line 34

def perform; end

#rollbackObject



35
# File 'lib/active_interactor/base.rb', line 35

def rollback; end