Class: BetterRailsDebugger::Parser::Ruby::Processor
- Inherits:
-
Parser::AST::Processor
- Object
- Parser::AST::Processor
- BetterRailsDebugger::Parser::Ruby::Processor
- Includes:
- ProcessorExtension
- Defined in:
- lib/better_rails_debugger/parser/ruby/processor.rb
Instance Attribute Summary collapse
-
#information ⇒ Object
readonly
Returns the value of attribute information.
Instance Method Summary collapse
- #cleanup_subscriptions ⇒ Object
-
#emit_signal(signal_name, node) ⇒ Object
Call all subscriptions for the given signal.
-
#initialize ⇒ Processor
constructor
A new instance of Processor.
- #setup ⇒ Object
-
#subscribe_signal(signal_name, step = :first_pass, &block) ⇒ Object
Subscribe to a particular signal.
- #unsubscribe(signal_name, hash) ⇒ Object
Methods included from ProcessorExtension
#get_full_class_name, #get_full_context_name, #params_to_hash
Constructor Details
#initialize ⇒ Processor
Returns a new instance of Processor.
4 5 6 |
# File 'lib/better_rails_debugger/parser/ruby/processor.rb', line 4 def initialize @information = ActiveSupport::HashWithIndifferentAccess.new end |
Instance Attribute Details
#information ⇒ Object (readonly)
Returns the value of attribute information.
3 4 5 |
# File 'lib/better_rails_debugger/parser/ruby/processor.rb', line 3 def information @information end |
Instance Method Details
#cleanup_subscriptions ⇒ Object
38 39 40 |
# File 'lib/better_rails_debugger/parser/ruby/processor.rb', line 38 def cleanup_subscriptions @subscriptions = Hash.new() end |
#emit_signal(signal_name, node) ⇒ Object
Call all subscriptions for the given signal
10 11 12 13 14 15 16 17 18 |
# File 'lib/better_rails_debugger/parser/ruby/processor.rb', line 10 def emit_signal(signal_name, node) @subscriptions ||= Hash.new() @runner ||= BetterRailsDebugger::Parser::Ruby::ContextRunner.new self (@subscriptions[signal_name] || {}).values.each do |block| @runner.node = node @runner.instance_eval &block # block.call(node) end end |
#setup ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/better_rails_debugger/parser/ruby/processor.rb', line 42 def setup (@extensions = ::BetterRailsDebugger::Parser::Ruby::Extension.sorted_extensions).map do |klass| instance = klass.new self instance.setup instance end end |
#subscribe_signal(signal_name, step = :first_pass, &block) ⇒ Object
Subscribe to a particular signal
24 25 26 27 28 29 30 |
# File 'lib/better_rails_debugger/parser/ruby/processor.rb', line 24 def subscribe_signal(signal_name, step=:first_pass, &block) key = SecureRandom.hex(5) @subscriptions ||= Hash.new() @subscriptions[signal_name] ||= Hash.new @subscriptions[signal_name][key] = block key end |
#unsubscribe(signal_name, hash) ⇒ Object
32 33 34 35 36 |
# File 'lib/better_rails_debugger/parser/ruby/processor.rb', line 32 def unsubscribe(signal_name, hash) @subscriptions ||= Hash.new() @subscriptions[signal_name] ||= Hash.new @subscriptions[signal_name].delete hash end |