Module: Newflow::ClassMethods

Defined in:
lib/newflow.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.state(name, *args) ⇒ Object



72
# File 'lib/newflow.rb', line 72

def @state_catcher.state(name, *args); @states << name; end

.statesObject



71
# File 'lib/newflow.rb', line 71

def @state_catcher.states; @states; end

Instance Method Details

#__define_query_methods(workflow_definition) ⇒ Object



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

def __define_query_methods(workflow_definition)
  @state_catcher = Object.new
  @state_catcher.instance_variable_set("@states", [])
  def @state_catcher.states; @states; end
  def @state_catcher.state(name, *args); @states << name; end
  @state_catcher.instance_eval &workflow_definition
  @state_catcher.states.each do |state|
    self.send(:define_method, "#{state}?") do 
      workflow.send("#{state}?")
    end
  end
end

#__workflow_definitionObject



81
82
83
# File 'lib/newflow.rb', line 81

def __workflow_definition
  @__workflow_definition
end

#define_workflow(&workflow_definition) ⇒ Object



63
64
65
66
# File 'lib/newflow.rb', line 63

def define_workflow(&workflow_definition)
  @__workflow_definition = workflow_definition
  __define_query_methods(workflow_definition)
end