Class: Itamae::Resource::Base::EvalContext
- Inherits:
-
Object
- Object
- Itamae::Resource::Base::EvalContext
- Defined in:
- lib/itamae/resource/base.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#not_if_command ⇒ Object
readonly
Returns the value of attribute not_if_command.
-
#notifications ⇒ Object
readonly
Returns the value of attribute notifications.
-
#only_if_command ⇒ Object
readonly
Returns the value of attribute only_if_command.
-
#subscriptions ⇒ Object
readonly
Returns the value of attribute subscriptions.
Instance Method Summary collapse
-
#initialize(resource) ⇒ EvalContext
constructor
A new instance of EvalContext.
- #method_missing(method, *args, &block) ⇒ Object
- #node ⇒ Object
- #not_if(command) ⇒ Object
- #notifies(action, resource_desc, timing = :delay) ⇒ Object
- #only_if(command) ⇒ Object
- #respond_to_missing?(method, include_private = false) ⇒ Boolean
- #subscribes(action, resource_desc, timing = :delay) ⇒ Object
Constructor Details
#initialize(resource) ⇒ EvalContext
Returns a new instance of EvalContext.
15 16 17 18 19 20 21 |
# File 'lib/itamae/resource/base.rb', line 15 def initialize(resource) @resource = resource @attributes = Hashie::Mash.new @notifications = [] @subscriptions = [] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/itamae/resource/base.rb', line 27 def method_missing(method, *args, &block) if @resource.class.defined_attributes[method] if args.size == 1 return @attributes[method] = args.first elsif args.size == 0 && block_given? return @attributes[method] = block elsif args.size == 0 return @attributes[method] end end super end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
9 10 11 |
# File 'lib/itamae/resource/base.rb', line 9 def attributes @attributes end |
#not_if_command ⇒ Object (readonly)
Returns the value of attribute not_if_command.
13 14 15 |
# File 'lib/itamae/resource/base.rb', line 13 def not_if_command @not_if_command end |
#notifications ⇒ Object (readonly)
Returns the value of attribute notifications.
10 11 12 |
# File 'lib/itamae/resource/base.rb', line 10 def notifications @notifications end |
#only_if_command ⇒ Object (readonly)
Returns the value of attribute only_if_command.
12 13 14 |
# File 'lib/itamae/resource/base.rb', line 12 def only_if_command @only_if_command end |
#subscriptions ⇒ Object (readonly)
Returns the value of attribute subscriptions.
11 12 13 |
# File 'lib/itamae/resource/base.rb', line 11 def subscriptions @subscriptions end |
Instance Method Details
#node ⇒ Object
57 58 59 |
# File 'lib/itamae/resource/base.rb', line 57 def node @resource.recipe.runner.node end |
#not_if(command) ⇒ Object
53 54 55 |
# File 'lib/itamae/resource/base.rb', line 53 def not_if(command) @not_if_command = command end |
#notifies(action, resource_desc, timing = :delay) ⇒ Object
41 42 43 |
# File 'lib/itamae/resource/base.rb', line 41 def notifies(action, resource_desc, timing = :delay) @notifications << Notification.new(@resource, action, resource_desc, timing) end |
#only_if(command) ⇒ Object
49 50 51 |
# File 'lib/itamae/resource/base.rb', line 49 def only_if(command) @only_if_command = command end |
#respond_to_missing?(method, include_private = false) ⇒ Boolean
23 24 25 |
# File 'lib/itamae/resource/base.rb', line 23 def respond_to_missing?(method, include_private = false) @resource.class.defined_attributes.has_key?(method) || super end |
#subscribes(action, resource_desc, timing = :delay) ⇒ Object
45 46 47 |
# File 'lib/itamae/resource/base.rb', line 45 def subscribes(action, resource_desc, timing = :delay) @subscriptions << Subscription.new(@resource, action, resource_desc, timing) end |