class Wright::Resource::Symlink
Symlink
resource, represents a symlink.
@example
link = Wright::Resource::Symlink.new('/tmp/fstab', to: '/etc/fstab') link.create
Attributes
to[RW]
@return [String] the symlink's intended target
Public Class Methods
new(name, args = {})
click to toggle source
Initializes a Symlink
.
@param name [String] the symlink's name @param args [Hash] the arguments @option args [Symbol] :action (:create) the action @option args [String] :to the symlink's target
Calls superclass method
Wright::Resource::new
# File lib/wright/resource/symlink.rb, line 18 def initialize(name, args = {}) super @action = args.fetch(:action, :create) @to = args.fetch(:to, nil) end
Public Instance Methods
create()
click to toggle source
Creates or updates the symlink.
@return [Bool] true if the symlink was updated and false
otherwise
# 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()
click to toggle source
Removes the symlink.
@return [Bool] true if the symlink was updated and false
otherwise
# File lib/wright/resource/symlink.rb, line 42 def remove might_update_resource do provider.remove end end