Module: Composable::Core::Command
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/composable/core/command.rb
Defined Under Namespace
Modules: ClassMethods
Classes: NotImplementedError
Instance Attribute Summary collapse
Instance Method Summary
collapse
Instance Attribute Details
#result ⇒ Object
Returns the value of attribute result.
10
11
12
|
# File 'lib/composable/core/command.rb', line 10
def result
@result
end
|
Instance Method Details
#call(raise_exception: false) ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/composable/core/command.rb', line 27
def call(raise_exception: false)
fail NotImplementedError unless defined?(super)
@called = true
@result = super()
raise Error, errors.full_messages.to_sentence if raise_exception && failure?
self
rescue Exception => exception
raise if raise_exception || !rescue_with_handler(exception)
self
end
|
#failure? ⇒ Boolean
46
47
48
|
# File 'lib/composable/core/command.rb', line 46
def failure?
called? && errors.any?
end
|
#success? ⇒ Boolean
42
43
44
|
# File 'lib/composable/core/command.rb', line 42
def success?
called? && !failure?
end
|