Module: Taskinator::Definition
- Defined in:
- lib/taskinator/definition.rb,
lib/taskinator/definition/builder.rb
Defined Under Namespace
Classes: Builder, ProcessAlreadyDefinedError, ProcessUndefinedError
Constant Summary collapse
- UndefinedProcessError =
for backward compatibility
ProcessUndefinedError
Instance Attribute Summary collapse
-
#queue ⇒ Object
Returns the value of attribute queue.
Instance Method Summary collapse
-
#create_process(*args) ⇒ Object
creates an instance of the process NOTE: the supplied @args are serialized and ultimately passed to each method of the defined process.
-
#create_process_remotely(*args) ⇒ Object
returns a placeholder process, with the uuid attribute of the actual process.
- #create_sub_process(*args) ⇒ Object
-
#define_process(*arg_list, &block) ⇒ Object
defines a process.
Instance Attribute Details
#queue ⇒ Object
Returns the value of attribute queue.
41 42 43 |
# File 'lib/taskinator/definition.rb', line 41 def queue @queue end |
Instance Method Details
#create_process(*args) ⇒ Object
creates an instance of the process NOTE: the supplied @args are serialized and ultimately passed to each method of the defined process
47 48 49 50 |
# File 'lib/taskinator/definition.rb', line 47 def create_process(*args) assert_valid_process_module _create_process_(args) end |
#create_process_remotely(*args) ⇒ Object
returns a placeholder process, with the uuid attribute of the actual process. the callee can call ‘reload` if required to get the actual process, once it has been built by the CreateProcessWorker
57 58 59 60 61 62 63 |
# File 'lib/taskinator/definition.rb', line 57 def create_process_remotely(*args) assert_valid_process_module uuid = SecureRandom.uuid Taskinator.queue.enqueue_create_process(self, uuid, args) Taskinator::Persistence::LazyLoader.new(Taskinator::Process, uuid) end |
#create_sub_process(*args) ⇒ Object
65 66 67 68 |
# File 'lib/taskinator/definition.rb', line 65 def create_sub_process(*args) assert_valid_process_module _create_process_(args, :subprocess => true) end |
#define_process(*arg_list, &block) ⇒ Object
defines a process
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/taskinator/definition.rb', line 12 def define_process(*arg_list, &block) raise ProcessAlreadyDefinedError if respond_to?(:_create_process_) define_singleton_method :_create_process_ do |args, ={}| # TODO: better validation of arguments # FIXME: arg_list should only contain an array of symbols raise ArgumentError, "wrong number of arguments (#{args.length} for #{arg_list.length})" if args.length < arg_list.length process = Process.define_sequential_process_for(self, ) # this may take long... up to users definition Taskinator.instrumenter.instrument(:create_process, :uuid => process.uuid) do Builder.new(process, self, *args).instance_eval(&block) end # instrument separately Taskinator.instrumenter.instrument(:save_process, :uuid => process.uuid) do process.save # if this is a root process, then add it to the list Persistence.add_process_to_list(process) unless [:subprocess] end process end end |