Class: Wright::Resource
- Inherits:
-
Object
- Object
- Wright::Resource
- Defined in:
- lib/wright/resource.rb,
lib/wright/resource/file.rb,
lib/wright/resource/package.rb,
lib/wright/resource/symlink.rb,
lib/wright/resource/directory.rb
Overview
Public: Resource base class.
Defined Under Namespace
Classes: Directory, File, Package, Symlink
Instance Attribute Summary collapse
-
#action ⇒ Object
Public: Get/Set the name Symbol of the method to be run by run_action.
-
#ignore_failure ⇒ Object
Public: Get/Set the ignore_failure attribute.
-
#name ⇒ Object
Public: Get/Set the resource’s name attribute.
-
#resource_name ⇒ Object
readonly
Public: Returns a compact resource name Symbol.
Instance Method Summary collapse
-
#initialize(name = nil) ⇒ Resource
constructor
Public: Initialize a Resource.
-
#on_update=(on_update) ⇒ Object
Public: Set an update action for a resource.
-
#run_action ⇒ Object
Public: Run the resource’s current action.
Constructor Details
#initialize(name = nil) ⇒ Resource
Public: Initialize a Resource.
name - The resource’s name.
12 13 14 15 16 17 18 19 |
# File 'lib/wright/resource.rb', line 12 def initialize(name = nil) @name = name @resource_name = Util.class_to_resource_name(self.class).to_sym @provider = provider_for_resource @action = nil @on_update = nil @ignore_failure = false end |
Instance Attribute Details
#action ⇒ Object
Public: Get/Set the name Symbol of the method to be run by run_action.
22 23 24 |
# File 'lib/wright/resource.rb', line 22 def action @action end |
#ignore_failure ⇒ Object
Public: Get/Set the ignore_failure attribute.
25 26 27 |
# File 'lib/wright/resource.rb', line 25 def ignore_failure @ignore_failure end |
#name ⇒ Object
39 40 41 |
# File 'lib/wright/resource.rb', line 39 def name @name end |
Instance Method Details
#on_update=(on_update) ⇒ Object
Public: Set an update action for a resource.
on_update - The block that is called if the resource is
updated. Has to respond to :call.
Returns nothing. Raises ArgumentError if on_update is not callable
57 58 59 60 61 62 63 |
# File 'lib/wright/resource.rb', line 57 def on_update=(on_update) if on_update.respond_to?(:call) || on_update.nil? @on_update = on_update else fail ArgumentError, "#{on_update} is not callable" end end |