Class: Itamae::Resource::Link

Inherits:
Base
  • Object
show all
Defined in:
lib/itamae/resource/link.rb

Instance Attribute Summary

Attributes inherited from Base

#attributes, #current_attributes, #notifications, #recipe, #resource_name, #subscriptions, #updated

Instance Method Summary collapse

Methods inherited from Base

#action_nothing, define_attribute, inherited, #initialize, #resource_type, #run

Constructor Details

This class inherits a constructor from Itamae::Resource::Base

Instance Method Details

#action_create(options) ⇒ Object


25
26
27
28
29
# File 'lib/itamae/resource/link.rb', line 25

def action_create(options)
  unless run_specinfra(:check_file_is_linked_to, attributes.link, attributes.to)
    run_specinfra(:link_file_to, attributes.link, attributes.to)
  end
end

#pre_actionObject


10
11
12
13
14
15
# File 'lib/itamae/resource/link.rb', line 10

def pre_action
  case @current_action
  when :create
    attributes.exist = true
  end
end

#set_current_attributesObject


17
18
19
20
21
22
23
# File 'lib/itamae/resource/link.rb', line 17

def set_current_attributes
  current.exist = run_specinfra(:check_file_is_link, attributes.link)

  if current.exist
    current.to = run_specinfra(:get_file_link_target, attributes.link).stdout.strip
  end
end