Sha256: 705d6c7652461abd70b109ed6467e5278b4dea4c145e79a6fe5234e02f07408e

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 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')
    #   link.to = '/etc/fstab'
    #   link.create
    class Symlink < Wright::Resource
      # Initializes a Symlink.
      #
      # @param name [String] the symlink's name
      def initialize(name)
        super
        @to = nil
        @action = :create
      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
        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

2 entries across 2 versions & 1 rubygems

Version Path
wright-0.2.0 lib/wright/resource/symlink.rb
wright-0.1.2 lib/wright/resource/symlink.rb