Class: EasyCommand::Result

Inherits:
Object
  • Object
show all
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

Direct Known Subclasses

Failure, Params, Success

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Methods included from ClassMethods

[]

Methods included from Chainable

included, #then

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

#errorsObject



15
16
17
# File 'lib/easy_command/result.rb', line 15

def errors
  EasyCommand::Errors.new
end

#failure?Boolean

Returns:

  • (Boolean)


19
# File 'lib/easy_command/result.rb', line 19

def failure?; false; end

#on_failure {|errors| ... } ⇒ Object

Yields:



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

Yields:



22
23
24
25
# File 'lib/easy_command/result.rb', line 22

def on_success
  yield(result) if success?
  self
end

#resultObject



11
12
13
# File 'lib/easy_command/result.rb', line 11

def result
  @content
end

#success?Boolean

Returns:

  • (Boolean)


20
# File 'lib/easy_command/result.rb', line 20

def success?; true; end