Class: HaveAPI::Fs::Components::UpdateActionDir

Inherits:
ActionDir show all
Defined in:
lib/haveapi/fs/components/update_action_dir.rb

Constant Summary

Constants included from Help

Help::SEARCH_PATH

Instance Attribute Summary

Attributes inherited from ActionDir

#action, #resource

Attributes inherited from HaveAPI::Fs::Component

#atime, #context, #ctime, #mtime

Instance Method Summary collapse

Methods inherited from ActionDir

#contents, #initialize, #setup, #title

Methods inherited from Directory

#contents, #directory?

Methods included from Help

find!, included

Methods inherited from HaveAPI::Fs::Component

#abspath, #bound=, #bound?, children_reader, component, #contents, #directory?, #executable?, #file?, #find, inherited, #initialize, #invalid?, #invalidate, #parent, #path, #readable?, #reset, #setup, #times, #title, #unsaved?, #use, #writable?

Constructor Details

This class inherits a constructor from HaveAPI::Fs::Components::ActionDir

Instance Method Details

#execObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/haveapi/fs/components/update_action_dir.rb', line 5

def exec
  ret = super

  return ret if !ret.is_a?(HaveAPI::Client::Response) || !ret.ok?

  data = children[:output].data
  return ret unless data.is_a?(HaveAPI::Client::ResourceInstance)

  params = @resource.actions[:show].params
  attrs = @resource.attributes

  data.attributes.each do |k, v|
    next if i(id _meta).include?(k) || !attrs.has_key?(k)

    if params[k][:type] == 'Resource'
      @resource.send("#{k}=", data.send(k))
      context[:resource_instance_dir].update_association(k)

    else
      @resource.send("#{k}=", v)
    end
  end

  ret
end