Sha256: a99636fc8ea6eeab7d78aa8459e58a6b62bedfe9a58b123d11eab58783a1ba75

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

require 'wright/resource'
require 'wright/dsl'

module Wright
  class Resource
    # Public: Symlink resource, represents a symlink.
    #
    # Examples
    #
    #   link = Wright::Resource::Symlink.new('/tmp/fstab')
    #   link.to = '/etc/fstab'
    #   link.create
    class Symlink < Wright::Resource
      # Public: Initialize a Symlink.
      #
      # name - The link's name.
      def initialize(name)
        super
        @to = nil
        @action = :create
      end

      # Public: Get/Set the link's target.
      attr_accessor :to

      # Public: Create or update the Symlink.
      #
      # Returns true if the symlink was updated and false otherwise.
      def create
        might_update_resource do
          @provider.create
        end
      end

      # Public: Remove the Symlink.
      #
      # Returns 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.1.1 lib/wright/resource/symlink.rb
wright-0.1.0 lib/wright/resource/symlink.rb