Class: Faire::Interactor
- Inherits:
-
Object
- Object
- Faire::Interactor
- Extended by:
- Forwardable
- Defined in:
- lib/faire/interactor.rb
Instance Attribute Summary collapse
-
#object ⇒ Object
readonly
Returns the value of attribute object.
Instance Method Summary collapse
- #errors ⇒ Object
- #fail? ⇒ Boolean
-
#initialize(object) ⇒ Interactor
constructor
A new instance of Interactor.
- #result ⇒ Object
- #success? ⇒ Boolean
- #validate_and_execute ⇒ Object
Constructor Details
#initialize(object) ⇒ Interactor
Returns a new instance of Interactor.
8 9 10 |
# File 'lib/faire/interactor.rb', line 8 def initialize(object) @object = object end |
Instance Attribute Details
#object ⇒ Object (readonly)
Returns the value of attribute object.
4 5 6 |
# File 'lib/faire/interactor.rb', line 4 def object @object end |
Instance Method Details
#errors ⇒ Object
21 22 23 |
# File 'lib/faire/interactor.rb', line 21 def errors @errors ||= object.errors end |
#fail? ⇒ Boolean
29 30 31 |
# File 'lib/faire/interactor.rb', line 29 def fail? errors.any? end |
#result ⇒ Object
17 18 19 |
# File 'lib/faire/interactor.rb', line 17 def result @result ||= execute if valid? end |
#success? ⇒ Boolean
25 26 27 |
# File 'lib/faire/interactor.rb', line 25 def success? errors.empty? end |
#validate_and_execute ⇒ Object
12 13 14 15 |
# File 'lib/faire/interactor.rb', line 12 def validate_and_execute validate result end |