Class: Itamae::Definition
- Inherits:
-
Resource::Base
- Object
- Resource::Base
- Itamae::Definition
- Defined in:
- lib/itamae/definition.rb
Class Attribute Summary collapse
-
.defined_in_recipe ⇒ Object
Returns the value of attribute defined_in_recipe.
-
.definition_block ⇒ Object
Returns the value of attribute definition_block.
Attributes inherited from Resource::Base
#attributes, #current_attributes, #notifications, #recipe, #resource_name, #subscriptions, #updated
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(*args) ⇒ Definition
constructor
A new instance of Definition.
- #run(*args) ⇒ Object
Methods inherited from Resource::Base
#action_nothing, define_attribute, #do_not_run_because_of_not_if?, #do_not_run_because_of_only_if?, inherited, #resource_type
Constructor Details
#initialize(*args) ⇒ Definition
Returns a new instance of Definition.
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/itamae/definition.rb', line 20 def initialize(*args) super r = Recipe::RecipeFromDefinition.new( runner, self.class.defined_in_recipe.path, ) recipe.children << r r.definition = self r.load(params: @attributes.merge(name: resource_name)) end |
Class Attribute Details
.defined_in_recipe ⇒ Object
Returns the value of attribute defined_in_recipe.
5 6 7 |
# File 'lib/itamae/definition.rb', line 5 def defined_in_recipe @defined_in_recipe end |
.definition_block ⇒ Object
Returns the value of attribute definition_block.
4 5 6 |
# File 'lib/itamae/definition.rb', line 4 def definition_block @definition_block end |
Class Method Details
.create_class(name, params, defined_in_recipe, &block) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/itamae/definition.rb', line 7 def create_class(name, params, defined_in_recipe, &block) Class.new(self).tap do |klass| klass.definition_block = block klass.defined_in_recipe = defined_in_recipe klass.define_attribute :action, default: :run params.each_pair do |key, value| klass.define_attribute key.to_sym, type: Object, default: value end end end |
Instance Method Details
#run(*args) ⇒ Object
33 34 35 |
# File 'lib/itamae/definition.rb', line 33 def run(*args) # nothing end |