Module: WFlow::Process::ClassMethods

Defined in:
lib/w_flow/process.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#wflow_nodesObject (readonly)

Returns the value of attribute wflow_nodes.



35
36
37
# File 'lib/w_flow/process.rb', line 35

def wflow_nodes
  @wflow_nodes
end

Class Method Details

.extended(klass) ⇒ Object



37
38
39
# File 'lib/w_flow/process.rb', line 37

def self.extended(klass)
  klass.instance_variable_set('@wflow_nodes', [])
end

Instance Method Details

#data_accessor(*keys) ⇒ Object



45
46
47
48
# File 'lib/w_flow/process.rb', line 45

def data_accessor(*keys)
  data_writer(*keys)
  data_reader(*keys)
end

#data_reader(*keys) ⇒ Object



56
57
58
59
60
# File 'lib/w_flow/process.rb', line 56

def data_reader(*keys)
  keys.each do |key|
    define_method(key) { flow.data.send(key.to_s) }
  end
end

#data_writer(*keys) ⇒ Object



50
51
52
53
54
# File 'lib/w_flow/process.rb', line 50

def data_writer(*keys)
  keys.each do |key|
    define_method("#{key}=") { |val| flow.data.send("#{key}=", val) }
  end
end

#execute(*components, &block) ⇒ Object



62
63
64
65
66
# File 'lib/w_flow/process.rb', line 62

def execute(*components, &block)
  options = components.last.is_a?(Hash) ? components.pop : {}
  components << block if block_given?
  wflow_nodes << Node.new(components, options)
end

#inherited(klass) ⇒ Object



41
42
43
# File 'lib/w_flow/process.rb', line 41

def inherited(klass)
  klass.instance_variable_set('@wflow_nodes', wflow_nodes.dup)
end

#run(params = {}) ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
# File 'lib/w_flow/process.rb', line 68

def run(params = {})
  unless params.nil? || params.is_a?(Hash)
    raise InvalidArgument, INVALID_RUN_PARAMS
  end

  supervisor = Supervisor.new(params)

  new.wflow_execute(supervisor)

  supervisor.report
end