Class: HaveAPI::Fs::Components::InstanceEdit
- Inherits:
-
ActionExecEdit
- Object
- HaveAPI::Fs::Component
- File
- ActionExecEdit
- HaveAPI::Fs::Components::InstanceEdit
- Defined in:
- lib/haveapi/fs/components/instance_edit.rb
Instance Attribute Summary
Attributes inherited from HaveAPI::Fs::Component
#atime, #context, #ctime, #mtime
Instance Method Summary collapse
Methods inherited from ActionExecEdit
#initialize, #writable?, #write
Methods inherited from File
#file?, #raw_close, #raw_open, #raw_read, #raw_sync, #raw_truncate, #raw_write, #size, #write
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::ActionExecEdit
Instance Method Details
#header ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/haveapi/fs/components/instance_edit.rb', line 5 def header "# This file is in YAML format. Lines beginning with a hash (#) are comments and\n# are ignored. The resource instance will be updated once this file is saved\n# and closed. The success of this operation can be later checked in\n# actions/update/status.\n# \n# To avoid updating a parameter, simply comment or delete it from this file.\n# Values of parameters that are not present when the file is closed are not\n# changed.\n#\n# To cancel the update, either do not save the file or save it empty.\n" end |
#read ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# 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 ⇒ Object
45 46 47 |
# File 'lib/haveapi/fs/components/instance_edit.rb', line 45 def save context[:resource_instance_dir].save end |
#save?(data) ⇒ Boolean
41 42 43 |
# File 'lib/haveapi/fs/components/instance_edit.rb', line 41 def save?(data) data.any? end |