Class: Minarai::Actions::Base
- Inherits:
-
Object
- Object
- Minarai::Actions::Base
show all
- Includes:
- ActiveModel::Validations
- Defined in:
- lib/minarai/actions/base.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(attributes) ⇒ Base
Returns a new instance of Base.
24
25
26
|
# File 'lib/minarai/actions/base.rb', line 24
def initialize(attributes)
@attributes = attributes
end
|
Instance Attribute Details
#backend ⇒ Object
Returns the value of attribute backend.
22
23
24
|
# File 'lib/minarai/actions/base.rb', line 22
def backend
@backend
end
|
Class Method Details
.attribute(name, options = {}) ⇒ Object
11
12
13
14
15
16
17
|
# File 'lib/minarai/actions/base.rb', line 11
def attribute(name, options = {})
default = options.delete(:default)
define_method(name) do
@attributes[name.to_s] || default
end
validates name, options
end
|
Instance Method Details
#call ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/minarai/actions/base.rb', line 28
def call
if complete?
Minarai::Logger.skip "[SKIP] #{name}"
else
run
if complete?
Minarai::Logger.done "[DONE] #{name}"
else
Minarai::Logger.fail "[FAIL] #{name}"
end
end
end
|
#error_messages ⇒ Object
45
46
47
|
# File 'lib/minarai/actions/base.rb', line 45
def error_messages
validation_error_messages
end
|
#run ⇒ Object
41
42
43
|
# File 'lib/minarai/actions/base.rb', line 41
def run
raise NotImplementedError
end
|