Class: Wright::Resource::Symlink

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

Overview

Public: 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

#on_update=, #run_action

Constructor Details

#initialize(name) ⇒ Symlink

Public: Initialize a Symlink.

name - The link’s name.



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

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

Instance Attribute Details

#toObject

Public: Get/Set the link’s target.



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

def to
  @to
end

Instance Method Details

#createObject

Public: Create or update the Symlink.

Returns true if the symlink was updated and false otherwise.



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

def create
  might_update_resource do
    @provider.create
  end
end

#removeObject

Public: Remove the Symlink.

Returns true if the symlink was updated and false otherwise.



38
39
40
41
42
# File 'lib/wright/resource/symlink.rb', line 38

def remove
  might_update_resource do
    @provider.remove
  end
end