Module: Card::Set::All::EventViz

Extended by:
Card::Set
Defined in:
tmpsets/set/mod018-developer/all/event_viz.rb

Overview

to see the order of events that will be executed on mycard.

Class Method Summary collapse

Instance Method Summary collapse

Methods included from I18nScope

#mod_name, #scope

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, #underscore

Methods included from Card::Set::AdvancedApi

#attachment, #ensure_set, #stage_method

Methods included from Format

#before, #format, layout_method_name, #view, view_method_name, view_setting_method_name, wrapper_method_name

Methods included from Inheritance

#include_set, #include_set_formats

Methods included from Basket

#abstract_basket, #add_to_basket, #basket, #unshift_basket

Methods included from Trait

#card_accessor, #card_reader, #card_writer, #require_field

Methods included from Event::Api

#event

Class Method Details

.source_locationObject



14
# File 'tmpsets/set/mod018-developer/all/event_viz.rb', line 14

def self.source_location; "/Users/ethan/dev/decko/gem/card/mod/developer/set/all/event_viz.rb"; end

Instance Method Details

#events(action) ⇒ Object

prevent events from showing up in the tree.



21
22
23
24
25
26
27
# File 'tmpsets/set/mod018-developer/all/event_viz.rb', line 21

def events action
  @action = action
  events =
    ActManager::Stage::STAGES.map { |stage| events_tree("#{stage}_stage") }
  @action = nil
  puts_events events
end

#events_tree(filt) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
# File 'tmpsets/set/mod018-developer/all/event_viz.rb', line 47

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



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'tmpsets/set/mod018-developer/all/event_viz.rb', line 31

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