Class: CPEE::Instances

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

Overview

}}}

Instance Method Summary collapse

Instance Method Details

#responseObject

{{{



292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
# File 'lib/cpee/implementation.rb', line 292

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