Class: Wright::Resource::Directory

Inherits:
Wright::Resource show all
Extended by:
Forwardable
Defined in:
lib/wright/resource/directory.rb

Overview

Directory resource, represents a directory.

Examples:

dir = Wright::Resource::Directory.new('/tmp/foobar')
dir.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

#log_error, #might_update_resource, #on_update=, #provider_for_resource, #provider_name, #resource_class, #run_action, #run_update_action

Constructor Details

#initialize(name) ⇒ Directory

Initializes a Directory.


20
21
22
23
24
25
# File 'lib/wright/resource/directory.rb', line 20

def initialize(name)
  super
  @mode = nil
  @owner = Wright::Util::FileOwner.new
  @action = :create
end

Instance Attribute Details

#groupString, Integer


41
# File 'lib/wright/resource/directory.rb', line 41

def_delegator :@owner, :group

#modeString, Integer


28
29
30
# File 'lib/wright/resource/directory.rb', line 28

def mode
  @mode
end

#ownerString, Integer


34
# File 'lib/wright/resource/directory.rb', line 34

def_delegator :@owner, :user_and_group=, :owner=

Instance Method Details

#createBool

Creates or updates the directory.


48
49
50
51
52
# File 'lib/wright/resource/directory.rb', line 48

def create
  might_update_resource do
    @provider.create
  end
end

#removeBool

Removes the directory.


58
59
60
61
62
# File 'lib/wright/resource/directory.rb', line 58

def remove
  might_update_resource do
    @provider.remove
  end
end