Class: Stove::Plugin::Base
- Inherits:
-
Object
- Object
- Stove::Plugin::Base
- Extended by:
- Mixin::Optionable, Mixin::Validatable
- Includes:
- Logify
- Defined in:
- lib/stove/plugins/base.rb
Instance Attribute Summary collapse
-
#cookbook ⇒ Object
readonly
Returns the value of attribute cookbook.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(cookbook, options = {}) ⇒ Base
constructor
A new instance of Base.
- #run ⇒ Object
- #run_actions ⇒ Object
- #run_validations ⇒ Object
Methods included from Mixin::Optionable
Methods included from Mixin::Validatable
Constructor Details
#initialize(cookbook, options = {}) ⇒ Base
Returns a new instance of Base.
27 28 29 |
# File 'lib/stove/plugins/base.rb', line 27 def initialize(cookbook, = {}) @cookbook, @options = cookbook, end |
Instance Attribute Details
#cookbook ⇒ Object (readonly)
Returns the value of attribute cookbook.
24 25 26 |
# File 'lib/stove/plugins/base.rb', line 24 def cookbook @cookbook end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
25 26 27 |
# File 'lib/stove/plugins/base.rb', line 25 def @options end |
Class Method Details
.actions ⇒ Object
16 17 18 |
# File 'lib/stove/plugins/base.rb', line 16 def actions @actions ||= [] end |
.run(description, &block) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/stove/plugins/base.rb', line 9 def run(description, &block) actions << Proc.new do |instance| log.info { description } instance.instance_eval(&block) end end |
Instance Method Details
#run ⇒ Object
31 32 33 34 |
# File 'lib/stove/plugins/base.rb', line 31 def run run_validations run_actions end |
#run_actions ⇒ Object
42 43 44 45 46 |
# File 'lib/stove/plugins/base.rb', line 42 def run_actions self.class.actions.each do |action| action.call(self) end end |
#run_validations ⇒ Object
36 37 38 39 40 |
# File 'lib/stove/plugins/base.rb', line 36 def run_validations self.class.validations.each do |id, validation| validation.run(cookbook, ) end end |