Skip to content

Instantly share code, notes, and snippets.

/t.rb

Created July 3, 2012 14:38
Show Gist options
  • Save anonymous/3040131 to your computer and use it in GitHub Desktop.
Save anonymous/3040131 to your computer and use it in GitHub Desktop.
require 'pp'
require 'ruote'
pdef = Ruote.define do
alice
concurrence do
bob
charly
end
participant :ref => 'doug'
end
dboard = Ruote::Dashboard.new(Ruote::HashStorage.new)
dboard.register do
alice Ruote::NoOpParticipant
participant /.+/, Ruote::StorageParticipant
end
def find_participants(dboard, tree, accu=[])
if tree[0] == 'participant'
accu << [ tree[1]['ref'], dboard.participant(tree[1]['ref']).class ]
elsif exp_class = dboard.context.expmap.expression_class(tree[0])
# do nothing
elsif pa = dboard.participant(tree[0])
accu << [ tree[0], pa.class ]
end
tree[2].each do |t|
find_participants(dboard, t, accu)
end
accu
end
pp find_participants(dboard, pdef)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment