Class: EasyCommand::Result
- Inherits:
-
Object
- Object
- EasyCommand::Result
- Extended by:
- ClassMethods
- Includes:
- Chainable
- Defined in:
- lib/easy_command/result.rb,
lib/easy_command/ruby-2-specific.rb,
lib/easy_command/ruby-3-specific.rb,
lib/easy_command/ruby-2-7-specific.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #errors ⇒ Object
- #failure? ⇒ Boolean
-
#initialize(content) ⇒ Result
constructor
A new instance of Result.
- #on_failure {|errors| ... } ⇒ Object
- #on_success {|result| ... } ⇒ Object
- #result ⇒ Object
- #success? ⇒ Boolean
Methods included from ClassMethods
Methods included from Chainable
Constructor Details
#initialize(content) ⇒ Result
Returns a new instance of Result.
7 8 9 |
# File 'lib/easy_command/result.rb', line 7 def initialize(content) @content = content end |
Instance Method Details
#errors ⇒ Object
15 16 17 |
# File 'lib/easy_command/result.rb', line 15 def errors EasyCommand::Errors.new end |
#failure? ⇒ Boolean
19 |
# File 'lib/easy_command/result.rb', line 19 def failure?; false; end |
#on_failure {|errors| ... } ⇒ Object
27 28 29 30 |
# File 'lib/easy_command/result.rb', line 27 def on_failure yield(errors) if failure? self end |
#on_success {|result| ... } ⇒ Object
22 23 24 25 |
# File 'lib/easy_command/result.rb', line 22 def on_success yield(result) if success? self end |
#result ⇒ Object
11 12 13 |
# File 'lib/easy_command/result.rb', line 11 def result @content end |
#success? ⇒ Boolean
20 |
# File 'lib/easy_command/result.rb', line 20 def success?; true; end |