Class: Wright::Resource::Symlink

Inherits:
Wright::Resource show all
Defined in:
lib/wright/resource/symlink.rb

Overview

Symlink resource, represents a symlink.

Examples:

link = Wright::Resource::Symlink.new('/tmp/fstab')
link.to = '/etc/fstab'
link.create

Instance Attribute Summary collapse

Attributes inherited from Wright::Resource

#action, #ignore_failure, #name, #resource_name

Instance Method Summary collapse

Methods inherited from Wright::Resource

#log_error, #might_update_resource, #on_update=, #provider_for_resource, #provider_name, #resource_class, #run_action, #run_update_action

Constructor Details

#initialize(name) ⇒ Symlink

Initializes a Symlink.


16
17
18
19
20
# File 'lib/wright/resource/symlink.rb', line 16

def initialize(name)
  super
  @to = nil
  @action = :create
end

Instance Attribute Details

#toString


23
24
25
# File 'lib/wright/resource/symlink.rb', line 23

def to
  @to
end

Instance Method Details

#createBool

Creates or updates the symlink.


29
30
31
32
33
34
# File 'lib/wright/resource/symlink.rb', line 29

def create
  fail ArgumentError, 'Symlink target undefined' unless @to
  might_update_resource do
    @provider.create
  end
end

#removeBool

Removes the symlink.


40
41
42
43
44
# File 'lib/wright/resource/symlink.rb', line 40

def remove
  might_update_resource do
    @provider.remove
  end
end