Class: Itamae::Definition::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/itamae/definition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(definition, params, &block) ⇒ Context

Returns a new instance of Context.



50
51
52
53
54
# File 'lib/itamae/definition.rb', line 50

def initialize(definition, params, &block)
  @definition = definition
  @params = params
  @children = RecipeChildren.new
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, name, &block) ⇒ Object



63
64
65
66
67
# File 'lib/itamae/definition.rb', line 63

def method_missing(method, name, &block)
  klass = Resource.get_resource_class(method)
  resource = klass.new(@definition.recipe, name, &block)
  @children << resource
end

Instance Attribute Details

#childrenObject (readonly)

Returns the value of attribute children.



48
49
50
# File 'lib/itamae/definition.rb', line 48

def children
  @children
end

#paramsObject (readonly)

Returns the value of attribute params.



47
48
49
# File 'lib/itamae/definition.rb', line 47

def params
  @params
end

Instance Method Details

#respond_to_missing?(method, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


56
57
58
59
60
61
# File 'lib/itamae/definition.rb', line 56

def respond_to_missing?(method, include_private = false)
  Resource.get_resource_class(method)
  true
rescue NameError
  false
end