class SakurraForm::Resource::Base
Attributes
cached_state[RW]
configuration[RW]
name[RW]
remote_state[RW]
resource_id[RW]
Public Class Methods
new(name, enable_remote = false)
click to toggle source
# File lib/sakurraform/resource/base.rb, line 7 def initialize(name, enable_remote = false) type = self.class.to_s.split('::').last.downcase @name = name @resource_id = resolve_id_by_name(type, name) @configuration = (SakurraForm::Plans[type.to_sym].select {|a| a.name == name}).first @cached_state = @resource_id ? collect_cached_state(type) : nil enable_remote = false unless @cached_state @remote_state = enable_remote ? collect_remote_state : nil end
Public Instance Methods
collect_cached_state(type)
click to toggle source
# File lib/sakurraform/resource/base.rb, line 17 def collect_cached_state(type) state_path = "state/#{type}/#{@resource_id}.yml" return {} unless File.exists?(state_path) YAML.load(File.read(state_path)) end
collect_remote_state()
click to toggle source
# File lib/sakurraform/resource/base.rb, line 23 def collect_remote_state # Override It end
flush_cached_state(type)
click to toggle source
# File lib/sakurraform/resource/base.rb, line 27 def flush_cached_state(type) state_path = "state/#{type}/#{@resource_id}.yml" return true unless File.exists?(state_path) File.delete(state_path) end