Class: Wright::Resource::Symlink
- Inherits:
-
Wright::Resource
- Object
- Wright::Resource
- Wright::Resource::Symlink
- Defined in:
- lib/wright/resource/symlink.rb
Overview
Symlink resource, represents a symlink.
Instance Attribute Summary collapse
-
#to ⇒ String
The symlink’s intended target.
Attributes inherited from Wright::Resource
#action, #ignore_failure, #name, #resource_name
Instance Method Summary collapse
-
#create ⇒ Bool
Creates or updates the symlink.
-
#initialize(name, args = {}) ⇒ Symlink
constructor
Initializes a Symlink.
-
#remove ⇒ Bool
Removes the symlink.
Methods inherited from Wright::Resource
Constructor Details
#initialize(name, args = {}) ⇒ Symlink
Initializes a Symlink.
18 19 20 21 22 |
# File 'lib/wright/resource/symlink.rb', line 18 def initialize(name, args = {}) super @action = args.fetch(:action, :create) @to = args.fetch(:to, nil) end |
Instance Attribute Details
#to ⇒ String
Returns the symlink’s intended target.
25 26 27 |
# File 'lib/wright/resource/symlink.rb', line 25 def to @to end |
Instance Method Details
#create ⇒ Bool
Creates or updates the symlink.
31 32 33 34 35 36 |
# File 'lib/wright/resource/symlink.rb', line 31 def create fail ArgumentError, 'Symlink target undefined' unless to might_update_resource do provider.create end end |
#remove ⇒ Bool
Removes the symlink.
42 43 44 45 46 |
# File 'lib/wright/resource/symlink.rb', line 42 def remove might_update_resource do provider.remove end end |