Class: Itamae::Definition::Context
- Inherits:
-
Object
- Object
- Itamae::Definition::Context
- Defined in:
- lib/itamae/definition.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Instance Method Summary collapse
-
#initialize(definition, params, &block) ⇒ Context
constructor
A new instance of Context.
- #method_missing(method, name, &block) ⇒ Object
- #respond_to_missing?(method, include_private = false) ⇒ Boolean
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
#children ⇒ Object (readonly)
Returns the value of attribute children.
48 49 50 |
# File 'lib/itamae/definition.rb', line 48 def children @children end |
#params ⇒ Object (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
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 |