Module: Task

Defined in:
lib/rbbt/workflow/task.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



5
6
7
# File 'lib/rbbt/workflow/task.rb', line 5

def description
  @description
end

#input_defaultsObject

Returns the value of attribute input_defaults.



5
6
7
# File 'lib/rbbt/workflow/task.rb', line 5

def input_defaults
  @input_defaults
end

#input_descriptionsObject

Returns the value of attribute input_descriptions.



5
6
7
# File 'lib/rbbt/workflow/task.rb', line 5

def input_descriptions
  @input_descriptions
end

#input_typesObject

Returns the value of attribute input_types.



5
6
7
# File 'lib/rbbt/workflow/task.rb', line 5

def input_types
  @input_types
end

#inputsObject

Returns the value of attribute inputs.



5
6
7
# File 'lib/rbbt/workflow/task.rb', line 5

def inputs
  @inputs
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/rbbt/workflow/task.rb', line 5

def name
  @name
end

#result_descriptionObject

Returns the value of attribute result_description.



5
6
7
# File 'lib/rbbt/workflow/task.rb', line 5

def result_description
  @result_description
end

#result_typeObject

Returns the value of attribute result_type.



5
6
7
# File 'lib/rbbt/workflow/task.rb', line 5

def result_type
  @result_type
end

Class Method Details

.setup(options = {}, &block) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/rbbt/workflow/task.rb', line 7

def self.setup(options = {}, &block)
  block.extend Task
  options = IndiferentHash.setup options
  block.singleton_methods.
    select{|method| method.to_s[-1] != "="[0]}.each{|method|
    if block.respond_to?(method + "=") and options.include? method.to_sym
      block.send(method + '=', options[method.to_sym]) 
    end
  }
  block
end

Instance Method Details

#exec(*args) ⇒ Object



46
47
48
49
50
51
52
53
# File 'lib/rbbt/workflow/task.rb', line 46

def exec(*args)
  case
  when (args.length == 1 and not inputs.nil? and inputs.length > 1 and Hash === args.first)
    self.call *take_input_values(IndiferentHash.setup(args.first))
  else
    self.call *args
  end
end

#exec_in(object, *args) ⇒ Object



55
56
57
58
59
60
61
62
# File 'lib/rbbt/workflow/task.rb', line 55

def exec_in(object, *args)
  case
  when (args.length == 1 and not inputs.nil? and inputs.length > 1 and Hash === args.first)
    object.instance_exec *IndiferentHash.setup(args.first).values_at(*inputs), &self
  else
    object.instance_exec *args, &self 
  end
end

#param_optionsObject



32
33
# File 'lib/rbbt/workflow/task.rb', line 32

def param_options
end

#parse_descriptionObject



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rbbt/workflow/task.rb', line 19

def parse_description
  if description =~ /\n\n/
    short_description, rest = description.match(/(.*?)\n\n(.*)/).values_at 1, 2
  else
    short_description = description
    rest = nil
  end

  if rest.nil?
    long_description = ""
  end
end

#persist_exec(filename, *args) ⇒ Object



64
65
66
67
68
# File 'lib/rbbt/workflow/task.rb', line 64

def persist_exec(filename, *args)
  Persist.persist "Task", @persistence_type, :file => filename do
    exec *args
  end
end

#persist_exec_in(filename, *args) ⇒ Object



70
71
72
73
74
# File 'lib/rbbt/workflow/task.rb', line 70

def persist_exec_in(filename, *args)
  Persist.persist "Task", @persistence_type, :file => filename do
    exec_in *args
  end
end

#take_input_values(input_values) ⇒ Object



35
36
37
38
39
40
41
42
43
44
# File 'lib/rbbt/workflow/task.rb', line 35

def take_input_values(input_values)
  return [] if @inputs.nil?
  values = []
  @inputs.each do |input|
    value = input_values[input]
    value = IndiferentHash.setup(@input_defaults || {})[input] if value.nil?
    values << value
  end
  values
end