Class: ActiveInteractor::Result
- Inherits:
-
Object
- Object
- ActiveInteractor::Result
- Defined in:
- lib/active_interactor.rb
Overview
Result of an operation.
Constant Summary collapse
- METHODS =
Concrete methods
Set.new(i[initialize success? failure?])
Instance Attribute Summary collapse
- #errors ⇒ ActiveModel::Errors readonly
Instance Method Summary collapse
- #failure? ⇒ Boolean
-
#initialize(payload, errors) ⇒ Result
constructor
A new instance of Result.
- #success? ⇒ Boolean
Constructor Details
#initialize(payload, errors) ⇒ Result
Returns a new instance of Result.
138 139 140 141 |
# File 'lib/active_interactor.rb', line 138 def initialize(payload, errors) @payload = payload.symbolize_keys @errors = errors end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name) ⇒ Object (private)
155 156 157 |
# File 'lib/active_interactor.rb', line 155 def method_missing(method_name, *) @payload.fetch(method_name) { super } end |
Instance Attribute Details
#errors ⇒ ActiveModel::Errors (readonly)
129 130 131 |
# File 'lib/active_interactor.rb', line 129 def errors @errors end |
Instance Method Details
#failure? ⇒ Boolean
149 150 151 |
# File 'lib/active_interactor.rb', line 149 def failure? errors.present? end |
#success? ⇒ Boolean
144 145 146 |
# File 'lib/active_interactor.rb', line 144 def success? !failure? end |