Class: Hookit::Resource::HookFile

Inherits:
Base
  • Object
show all
Defined in:
lib/hookit/resource/hook_file.rb

Instance Attribute Summary

Attributes inherited from Base

#dict

Instance Method Summary collapse

Methods inherited from Base

#action, actions, #can_run?, default_action, #default_action, field, #not_if, #only_if

Constructor Details

#initialize(name) ⇒ HookFile

Returns a new instance of HookFile.



14
15
16
17
18
# File 'lib/hookit/resource/hook_file.rb', line 14

def initialize(name)
  path name unless path
  source ::File.basename(name)
  super
end

Instance Method Details

#run(action) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/hookit/resource/hook_file.rb', line 20

def run(action)
  case action
  when :create
    create!
    chown!
    chmod!            
  when :create_if_missing
    create_if_missing!
    chown!
    chmod!
  when :delete
    delete!
  when :touch
    touch!
  end
end