Sha256: 776c73719f7ef039d5932d1c904a99a0ccecd9455106249e2333f7a24075ab22
Contents?: true
Size: 1.56 KB
Versions: 3
Compression:
Stored size: 1.56 KB
Contents
module HaveAPI::Fs::Components class ActionOutput < Directory component :action_output attr_reader :action_dir attr_accessor :data def initialize(action_dir, *args) super(*args) @action_dir = action_dir if %i(hash_list object_list).include?(@action_dir.action.output_layout.to_sym) @list = true end end def contents ret = super return ret unless @data if @list if @data.is_a?(HaveAPI::Client::ResourceInstanceList) ret.concat(@data.map { |v| v.id.to_s }) else ret.concat(@data.response.map { |v| v[:id].to_s }) end else ret.concat(parameters.keys.map(&:to_s)) end ret end def parameters @action_dir.action.params end def title 'Output parameters' end protected def new_child(name) if child = super child elsif !@data nil elsif @list id = name.to_s.to_i if @data.is_a?(HaveAPI::Client::ResourceInstanceList) param = @data.detect { |v| v.id == id } [ResourceInstanceDir, param] else param = @data.response.detect { |v| v[:id] == id } [ListItem, @action_dir.action, :output, param] end elsif parameters.has_key?(name) [ Parameter, @action_dir.action, name, :output, @data.is_a?(HaveAPI::Client::ResourceInstance) ? @data : @data.response, ] else nil end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
haveapi-fs-0.8.0 | lib/haveapi/fs/components/action_output.rb |
haveapi-fs-0.7.1 | lib/haveapi/fs/components/action_output.rb |
haveapi-fs-0.7.0 | lib/haveapi/fs/components/action_output.rb |