Class: Ruote::ExpressionMap

Inherits:
Object
  • Object
show all
Defined in:
lib/ruote/svc/expression_map.rb

Overview

Mapping from expression names (sequence, concurrence, …) to expression classes (Ruote::SequenceExpression, Ruote::ConcurrenceExpression, …)

Requiring this ruote/svc/expression_map.rb file will automatically load all the expressions in ruote/exp/fe_*.rb.

When the ExpressionMap is instantiated by the engine, it will look at the Ruote::Exp namespace and register as expression any constant in there whose name ends with “Expression”, like “SequenceExpression” or “ParticipantExpression”.

So adding expressions to ruote should be as simple as making sure the engine sees your classes under Ruote::Exp before it instantiates this expression map (so that the expression map will automatically register your expressions).

Instance Method Summary collapse

Constructor Details

#initialize(worker) ⇒ ExpressionMap

Will load any expression in the Ruote::Exp

namespace and map

its names to its class.


66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/ruote/svc/expression_map.rb', line 66

def initialize(worker)

  @map = {}

  Ruote::Exp.constants.each do |con|

    con = con.to_s
    next unless con.match(/Expression$/)

    cla = Ruote::Exp.const_get(con)
    next unless cla.respond_to?(:expression_names)

    add(cla)
  end
end

Instance Method Details

#expression_class(exp_name) ⇒ Object

Returns the expression class for the given expression name


84
85
86
87
# File 'lib/ruote/svc/expression_map.rb', line 84

def expression_class(exp_name)

  @map[exp_name]
end