Class: Rsodx::Interactor
- Inherits:
-
Object
show all
- Includes:
- Interactor
- Defined in:
- lib/rsodx/interactor.rb
Class Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Class Attribute Details
.contract_class ⇒ Object
Returns the value of attribute contract_class.
8
9
10
|
# File 'lib/rsodx/interactor.rb', line 8
def contract_class
@contract_class
end
|
Class Method Details
.contract(&block) ⇒ Object
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/rsodx/interactor.rb', line 10
def contract(&block)
before do
self.class.contract_class ||= Class.new(Rsodx::Contract, &block)
contract = self.class.contract_class.new.call(context.params.to_h)
if contract.failure?
halt(400, contract.errors.to_h)
end
end
end
|
Instance Method Details
#halt(code, message) ⇒ Object
22
23
24
25
|
# File 'lib/rsodx/interactor.rb', line 22
def halt(code, message)
log_error(code, message)
context.fail!(error_code: code, error: Rsodx::Error::ContractError.new(message))
end
|