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.
-
#verify_commands ⇒ Object
readonly
Returns the value of attribute verify_commands.
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
- #run_command(*args) ⇒ Object
- #subscribes(action, resource_desc, timing = :delay) ⇒ Object
-
#verify(command) ⇒ Object
Experimental.
Constructor Details
#initialize(resource) ⇒ EvalContext
Returns a new instance of EvalContext.
15 16 17 18 19 20 21 22 |
# File 'lib/itamae/resource/base.rb', line 15 def initialize(resource) @resource = resource @attributes = Itamae::Mash.new @notifications = [] @subscriptions = [] @verify_commands = [] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/itamae/resource/base.rb', line 28 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.
8 9 10 |
# File 'lib/itamae/resource/base.rb', line 8 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.
9 10 11 |
# File 'lib/itamae/resource/base.rb', line 9 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.
10 11 12 |
# File 'lib/itamae/resource/base.rb', line 10 def subscriptions @subscriptions end |
#verify_commands ⇒ Object (readonly)
Returns the value of attribute verify_commands.
11 12 13 |
# File 'lib/itamae/resource/base.rb', line 11 def verify_commands @verify_commands end |
Instance Method Details
#node ⇒ Object
58 59 60 |
# File 'lib/itamae/resource/base.rb', line 58 def node @resource.recipe.runner.node end |
#not_if(command) ⇒ Object
54 55 56 |
# File 'lib/itamae/resource/base.rb', line 54 def not_if(command) @not_if_command = command end |
#notifies(action, resource_desc, timing = :delay) ⇒ Object
42 43 44 |
# File 'lib/itamae/resource/base.rb', line 42 def notifies(action, resource_desc, timing = :delay) @notifications << Notification.create(@resource, action, resource_desc, timing) end |
#only_if(command) ⇒ Object
50 51 52 |
# File 'lib/itamae/resource/base.rb', line 50 def only_if(command) @only_if_command = command end |
#respond_to_missing?(method, include_private = false) ⇒ Boolean
24 25 26 |
# File 'lib/itamae/resource/base.rb', line 24 def respond_to_missing?(method, include_private = false) @resource.class.defined_attributes.has_key?(method) || super end |
#run_command(*args) ⇒ Object
62 63 64 |
# File 'lib/itamae/resource/base.rb', line 62 def run_command(*args) @resource.recipe.runner.backend.run_command(*args) end |
#subscribes(action, resource_desc, timing = :delay) ⇒ Object
46 47 48 |
# File 'lib/itamae/resource/base.rb', line 46 def subscribes(action, resource_desc, timing = :delay) @subscriptions << Subscription.create(@resource, action, resource_desc, timing) end |
#verify(command) ⇒ Object
Experimental
67 68 69 |
# File 'lib/itamae/resource/base.rb', line 67 def verify(command) @verify_commands << command end |