Class: Bizflow::BusinessModel::Process

Inherits:
SimpleWrapper
  • Object
show all
Includes:
Lib::Callbackable
Defined in:
lib/bizflow/business_model/process.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from SimpleWrapper

wrap, wraps

Class Method Details

.create_process(blueprint_id, creator_id) ⇒ Object



33
34
35
# File 'lib/bizflow/business_model/process.rb', line 33

def self.create_process(blueprint_id, creator_id)
  Bizflow::Lib::ProcessBuilder.new.build(blueprint_id, creator_id)
end

Instance Method Details

#finishObject



29
30
31
# File 'lib/bizflow/business_model/process.rb', line 29

def finish
  update(finished_at: Time.now)
end

#start(runner_id, &block) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/bizflow/business_model/process.rb', line 13

def start(runner_id, &block)

  setup_callbacks(&block)
  
  if runned_at != nil
    callback(:already_started, data: self, message: "process has already been started") and return 
  end
  
  ph = Bizflow::BusinessModel::Head.wrap(head)
  ph.jump(start_action_id)
  update(runner_id: runner_id, runned_at: Time.now)
  
  callback(:success, data: self, message: "process started successfully")

end