class HaveAPI::Fs::Components::InstanceEdit

Public Instance Methods

header() click to toggle source
# File lib/haveapi/fs/components/instance_edit.rb, line 5
    def header
      <<END
# This file is in YAML format. Lines beginning with a hash (#) are comments and
# are ignored. The resource instance will be updated once this file is saved
# and closed. The success of this operation can be later checked in
# actions/update/status.
# 
# To avoid updating a parameter, simply comment or delete it from this file.
# Values of parameters that are not present when the file is closed are not
# changed.
#
# To cancel the update, either do not save the file or save it empty.
END
    end
read() click to toggle source
# File lib/haveapi/fs/components/instance_edit.rb, line 20
def read
  ret = header + "\n"
  instance_dir = context[:resource_instance_dir]

  @action_dir.action.input_params.each do |name, p|
    if p[:type] == 'Resource'
      v = instance_dir.resource.attributes[name][ p[:value_id].to_sym ]

    else
      v = instance_dir.resource.attributes[name]
    end

    ret += "# #{p[:label]}; #{p[:type]}\n"
    ret += "# #{p[:description]}\n"
    ret += "# Defaults to '#{p[:default]}'\n" unless p[:default].nil?
    ret += "##{name}: #{v}\n\n"
  end

  ret
end
save() click to toggle source
# File lib/haveapi/fs/components/instance_edit.rb, line 45
def save
  context[:resource_instance_dir].save
end
save?(data) click to toggle source
# File lib/haveapi/fs/components/instance_edit.rb, line 41
def save?(data)
  data.any?
end