Class: CPEE::Instances

Inherits:
Riddl::Implementation
  • Object
show all
Defined in:
lib/cpee/implementation.rb

Overview

{{{

Instance Method Summary collapse

Instance Method Details

#responseObject



260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
# File 'lib/cpee/implementation.rb', line 260

def response
  opts = @a[0]
  if opts[:see_instances] || @h['SEE_INSTANCES'] == 'true'
    Riddl::Parameter::Complex.new("wis","text/xml") do
      ins = XML::Smart::string('<instances/>')
      CPEE::Persistence::each_object(opts) do |instance|
        info = CPEE::Persistence::extract_item(instance,opts,'attributes/info')
        uuid = CPEE::Persistence::extract_item(instance,opts,'attributes/uuid')
        state = CPEE::Persistence::extract_item(instance,opts,'state')
        state_changed = CPEE::Persistence::extract_item(instance,opts,'state/@changed')
        ins.root.add('instance', info,  'uuid' => uuid, 'id' => instance, 'state' => state, 'state_changed' => state_changed )
      end
      ins.to_s
    end
  else
    Riddl::Parameter::Complex.new("wis","text/xml",'<instances><!-- instances list disabled. --></instances>')
  end
end