Module: Comandor
- Defined in:
- lib/comandor.rb,
lib/comandor/version.rb
Overview
Service Objects
Constant Summary collapse
- VERSION =
'0.1.2'
Instance Attribute Summary collapse
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Class Method Summary collapse
-
.extended(base) ⇒ Object
Callback on ‘extend Comandor`.
Instance Method Summary collapse
-
#error(key, message) ⇒ self
Add new error to key array.
-
#errors ⇒ Hash<Symbol => Array>
List of errors.
-
#fail? ⇒ Boolean
(also: #failed?)
Are we failed?.
- #perform(*args, &block) ⇒ self
-
#success? ⇒ Boolean
Are we done here?.
Instance Attribute Details
#result ⇒ Object (readonly)
Returns the value of attribute result.
7 8 9 |
# File 'lib/comandor.rb', line 7 def result @result end |
Class Method Details
.extended(base) ⇒ Object
Callback on ‘extend Comandor`
10 11 12 |
# File 'lib/comandor.rb', line 10 def self.extended(base) base.prepend(self) end |
Instance Method Details
#error(key, message) ⇒ self
Add new error to key array
26 27 28 29 30 31 32 33 34 |
# File 'lib/comandor.rb', line 26 def error(key, ) errors[key] ||= [] if .is_a? Array errors[key] = errors[key] + else errors[key] << end self end |
#errors ⇒ Hash<Symbol => Array>
List of errors
51 52 53 |
# File 'lib/comandor.rb', line 51 def errors @errors ||= {} end |
#fail? ⇒ Boolean Also known as: failed?
Are we failed?
44 45 46 |
# File 'lib/comandor.rb', line 44 def fail? done? && errors? end |
#perform(*args, &block) ⇒ self
15 16 17 18 19 20 |
# File 'lib/comandor.rb', line 15 def perform(*args, &block) raise NoMethodError unless defined?(:perform) @result = super @done = true self end |
#success? ⇒ Boolean
Are we done here?
38 39 40 |
# File 'lib/comandor.rb', line 38 def success? done? && !errors? end |