Module: SimpleCommand
- Defined in:
- lib/simple_command.rb,
lib/simple_command/errors.rb,
lib/simple_command/version.rb
Defined Under Namespace
Modules: ClassMethods
Classes: Errors, NotImplementedError
Constant Summary
collapse
- VERSION =
'0.1.0'
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Instance Attribute Details
#result ⇒ Object
Returns the value of attribute result.
5
6
7
|
# File 'lib/simple_command.rb', line 5
def result
@result
end
|
Class Method Details
.prepended(base) ⇒ Object
13
14
15
|
# File 'lib/simple_command.rb', line 13
def self.prepended(base)
base.extend ClassMethods
end
|
Instance Method Details
#call ⇒ Object
17
18
19
20
21
22
23
24
|
# File 'lib/simple_command.rb', line 17
def call
fail NotImplementedError unless defined?(super)
@called = true
@result = super
self
end
|
#errors ⇒ Object
35
36
37
38
39
|
# File 'lib/simple_command.rb', line 35
def errors
return super if defined?(super)
@errors ||= Errors.new
end
|
#failure? ⇒ Boolean
31
32
33
|
# File 'lib/simple_command.rb', line 31
def failure?
called? && errors.any?
end
|
#success? ⇒ Boolean
Also known as:
successful?
26
27
28
|
# File 'lib/simple_command.rb', line 26
def success?
called? && !failure?
end
|