Class: CPEE::Properties::PutState

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

Overview

}}}

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.run(id, opts, state) ⇒ Object



238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
# File 'lib/cpee/implementation_properties.rb', line 238

def self::run(id,opts,state)
  case state
    when 'running'
      seh = Object.const_get('CPEE::ExecutionHandler::' + CPEE::Persistence::extract_item(id,opts,'executionhandler').capitalize)
      seh::prepare(id,opts)
      seh::run(id,opts)
    when 'stopping'
      seh = Object.const_get('CPEE::ExecutionHandler::' + CPEE::Persistence::extract_item(id,opts,'executionhandler').capitalize)
      if seh::stop(id,opts) # process is not running anyway, so change redis
        PutState::set id, opts, 'stopped'
      end
    else
      PutState::set id, opts, state
  end
end

.set(id, opts, state) ⇒ Object

{{{



234
235
236
# File 'lib/cpee/implementation_properties.rb', line 234

def self::set(id,opts,state)
  CPEE::Persistence::set_item(id,opts,'state',:state => state, :attributes => CPEE::Persistence::extract_list(id,opts,'attributes').to_h)
end

Instance Method Details

#responseObject



254
255
256
257
258
259
260
261
262
263
264
# File 'lib/cpee/implementation_properties.rb', line 254

def response
  id = @a[0]
  opts = @a[1]
  state = @p[0].value
  if opts[:statemachine].setable? id, state
    PutState::run id, opts, state
  else
    @status = 422
  end
  nil
end