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



226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
# File 'lib/cpee/implementation_properties.rb', line 226

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
      ### Most probably this is never needed. Lets see.
      PutState::set id, opts, state
  end
end

.set(id, opts, state) ⇒ Object

{{{



222
223
224
# File 'lib/cpee/implementation_properties.rb', line 222

def self::set(id,opts,state)
  CPEE::Persistence::set_item(id,opts,'state',:state => state, :timestamp => Time.now.xmlschema(3))
end

Instance Method Details

#responseObject



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

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