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



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

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

{{{



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

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



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

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