Sha256: 6247b1b28b4875023900defa320abbe51d5dde86c5e42e481a31457743027087
Contents?: true
Size: 1.31 KB
Versions: 1
Compression:
Stored size: 1.31 KB
Contents
require 'wright/resource' require 'wright/dsl' module Wright class Resource # Symlink resource, represents a symlink. # # @example # link = Wright::Resource::Symlink.new('/tmp/fstab', to: '/etc/fstab') # link.create class Symlink < Wright::Resource # 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 def initialize(name, args = {}) super @action = args.fetch(:action, :create) @to = args.fetch(:to, nil) end # @return [String] the symlink's intended target attr_accessor :to # Creates or updates the symlink. # # @return [Bool] true if the symlink was updated and false # otherwise def create fail ArgumentError, 'Symlink target undefined' unless to might_update_resource do provider.create end end # Removes the symlink. # # @return [Bool] true if the symlink was updated and false # otherwise def remove might_update_resource do provider.remove end end end end end Wright::DSL.register_resource(Wright::Resource::Symlink)
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
wright-0.5.0 | lib/wright/resource/symlink.rb |