Module: Card::Set::All::EventViz
- Extended by:
- Card::Set
- Defined in:
- tmpsets/set/mod014-developer/all/event_viz.rb
Constant Summary
Constants included from Format
Instance Method Summary collapse
-
#events(action) ⇒ Object
the events method is a developer's tool for visualizing the event order for a given card.
- #events_tree(filt) ⇒ Object
-
#puts_events(events, prefix = "", depth = 0) ⇒ Object
private.
Methods included from I18nScope
Methods included from Loader
#clean_empty_module_from_hash, #clean_empty_modules, #extended, #process_base_modules, #register_set
Methods included from Helpers
#abstract_set?, #all_set?, #num_set_parts, #shortname
Methods included from Card::Set::AdvancedApi
#attachment, #ensure_set, #stage_method
Methods included from Format
#all_set_format_mod!, #define_on_format, #format, #register_set_format, #view
Methods included from Inheritance
#include_set, #include_set_formats
Methods included from Basket
#abstract_basket, #add_to_basket, #basket
Methods included from Trait
#card_accessor, #card_reader, #card_writer
Methods included from Event
Instance Method Details
#events(action) ⇒ Object
the events method is a developer's tool for visualizing the event order for a given card. For example, from a console you might run
puts mycard.events :update
to see the order of events that will be executed on mycard. The indention and arrows (^v) indicate event dependencies.
Note: as of yet, the functionality is a bit rough. It does not display events that are called directly from within other events, and certain event requirements (like the presence of a 'current_act') may prevent events from showing up in the tree.
19 20 21 22 23 24 |
# File 'tmpsets/set/mod014-developer/all/event_viz.rb', line 19 def events action @action = action events = Card::Stage::STAGES.map { |stage| events_tree("#{stage}_stage") } @action = nil puts_events events end |
#events_tree(filt) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'tmpsets/set/mod014-developer/all/event_viz.rb', line 44 def events_tree filt hash = { name: filt } if respond_to? "_#{filt}_callbacks" send("_#{filt}_callbacks").each do |callback| next unless callback.applies? self hash[callback.kind] ||= [] hash[callback.kind] << events_tree(callback.filter) end end hash end |
#puts_events(events, prefix = "", depth = 0) ⇒ Object
private
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'tmpsets/set/mod014-developer/all/event_viz.rb', line 28 def puts_events events, prefix="", depth=0 r = "" depth += 1 events.each do |e| space = " " * (depth * 2) # FIXME: this is not right. before and around callbacks are processed in # declaration order regardless of kind. not all befores then all arounds e[:before] && r += puts_events(e[:before], space + "v ", depth) e[:around] && r += puts_events(e[:around], space + "vv ", depth) r += "#{prefix}#{e[:name]}\n" e[:after] && r += puts_events(e[:after].reverse, space + "^ ", depth) end r end |