class CPEE::Properties::PutState

Public Class Methods

run(id,opts,state) click to toggle source
# 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) click to toggle source
# 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

Public Instance Methods

response() click to toggle source
# 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