class FlowChart::State

Driver for States in FlowChart

Attributes

before_and_after_works[RW]
flowstatename[RW]

Public Class Methods

new(flowstatename, &flowblock) click to toggle source
# File lib/flowchart/flow_processor.rb, line 10
def initialize(flowstatename, &flowblock)
  @flowstatename,@before_and_after_works = flowstatename,Hash.new
  instance_eval(&flowblock) if block_given?
end

Public Instance Methods

postprocess(method = nil, &block) click to toggle source
Optional in State flow

PostProcess Things-To-Do before entering this state => Usecase Notifications

Takes a proc or instance method as block
# File lib/flowchart/flow_processor.rb, line 25
def postprocess(method = nil, &block)
  @before_and_after_works[:postprocess] = method.nil? ? block : method
end
preprocess(method = nil, &block) click to toggle source
Optional in State flow

Preprocess Things-To-Do before entering this state => Usecase Notifications

Takes a proc or instance method as block
# File lib/flowchart/flow_processor.rb, line 18
def preprocess(method = nil, &block)
  @before_and_after_works[:preprocess] = method.nil? ? block : method
end
process_flow(action,base) click to toggle source

Defines how the flow for a State executes with preprocess and postprocess

# File lib/flowchart/flow_processor.rb, line 30
def process_flow(action,base)
  action = @before_and_after_works[action.to_sym]
  case action
  when Symbol, String
    base.send(action)
  when Proc
    action.call(base)
  end
end