-
-
Save anonymous/3040131 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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