Class: Itamae::Definition

Inherits:
Resource::Base show all
Defined in:
lib/itamae/definition.rb

Defined Under Namespace

Classes: Context

Instance Attribute Summary

Attributes inherited from Resource::Base

#attributes, #current_attributes, #notifications, #recipe, #resource_name, #subscriptions, #updated

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource::Base

#action_nothing, define_attribute, inherited, #resource_type, #run

Constructor Details

#initialize(*args) ⇒ Definition

Returns a new instance of Definition.



26
27
28
29
30
# File 'lib/itamae/definition.rb', line 26

def initialize(*args)
  super

  construct_resources
end

Class Method Details

.create_class(name, params, &block) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/itamae/definition.rb', line 6

def create_class(name, params, &block)
  Class.new(self).tap do |klass|
    klass.definition_block = block

    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

.definition_blockObject



21
22
23
# File 'lib/itamae/definition.rb', line 21

def definition_block
  @definition_block
end

.definition_block=(block) ⇒ Object



17
18
19
# File 'lib/itamae/definition.rb', line 17

def definition_block=(block)
  @definition_block = block
end

Instance Method Details

#action_run(options) ⇒ Object



32
33
34
# File 'lib/itamae/definition.rb', line 32

def action_run(options)
  @children.run(options)
end