Module: Comandor
- Defined in:
- lib/comandor.rb,
lib/comandor/version.rb
Overview
Service Objects
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- VERSION =
'0.1.3'
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 13 |
# File 'lib/comandor.rb', line 10 def self.extended(base) base.prepend(self) base.extend(ClassMethods) end |
Instance Method Details
#error(key, message) ⇒ self
Add new error to key array
34 35 36 37 38 39 40 41 42 |
# File 'lib/comandor.rb', line 34 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
59 60 61 |
# File 'lib/comandor.rb', line 59 def errors @errors ||= {} end |
#fail? ⇒ Boolean Also known as: failed?
Are we failed?
52 53 54 |
# File 'lib/comandor.rb', line 52 def fail? done? && errors? end |
#perform(*args, &block) ⇒ self
23 24 25 26 27 28 |
# File 'lib/comandor.rb', line 23 def perform(*args, &block) raise NoMethodError unless defined?(:perform) @result = super @done = true self end |
#success? ⇒ Boolean
Are we done here?
46 47 48 |
# File 'lib/comandor.rb', line 46 def success? done? && !errors? end |