Module: Taskinator::Definition

Defined in:
lib/taskinator/definition.rb,
lib/taskinator/definition/builder.rb

Defined Under Namespace

Classes: Builder, UndefinedProcessError

Instance Method Summary collapse

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



28
29
30
31
# File 'lib/taskinator/definition.rb', line 28

def create_process(*args)
  raise UndefinedProcessError unless respond_to?(:_create_process_)
  _create_process_(args)
end

#create_sub_process(*args) ⇒ Object



33
34
35
36
# File 'lib/taskinator/definition.rb', line 33

def create_sub_process(*args)
  raise UndefinedProcessError unless respond_to?(:_create_process_)
  _create_process_(args, :subprocess => true)
end

#define_process(*arg_list, &block) ⇒ Object

defines a process



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/taskinator/definition.rb', line 6

def define_process(*arg_list, &block)
  define_singleton_method :_create_process_ do |args, options={}|

    # 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)
    Builder.new(process, self, *args).instance_eval(&block)
    process.save

    # if this is a root process, then add it to the list
    Persistence.add_process_to_list(process) unless options[:subprocess]

    process
  end
end