Class: Graphiti::Debugger
Class Attribute Summary collapse
-
.chunks ⇒ Object
Returns the value of attribute chunks.
-
.debug_models ⇒ Object
Returns the value of attribute debug_models.
-
.enabled ⇒ Object
Returns the value of attribute enabled.
-
.preserve ⇒ Object
Returns the value of attribute preserve.
-
.pry ⇒ Object
Returns the value of attribute pry.
Class Method Summary collapse
- .debug ⇒ Object
- .flush ⇒ Object
- .on_data(name, start, stop, id, payload) ⇒ Object
- .on_render(name, start, stop, id, payload) ⇒ Object
- .to_a ⇒ Object
Class Attribute Details
.chunks ⇒ Object
Returns the value of attribute chunks.
7 8 9 |
# File 'lib/graphiti/debugger.rb', line 7 def chunks @chunks end |
.debug_models ⇒ Object
Returns the value of attribute debug_models.
7 8 9 |
# File 'lib/graphiti/debugger.rb', line 7 def debug_models @debug_models end |
.enabled ⇒ Object
Returns the value of attribute enabled.
7 8 9 |
# File 'lib/graphiti/debugger.rb', line 7 def enabled @enabled end |
.preserve ⇒ Object
Returns the value of attribute preserve.
7 8 9 |
# File 'lib/graphiti/debugger.rb', line 7 def preserve @preserve end |
.pry ⇒ Object
Returns the value of attribute pry.
7 8 9 |
# File 'lib/graphiti/debugger.rb', line 7 def pry @pry end |
Class Method Details
.debug ⇒ Object
106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/graphiti/debugger.rb', line 106 def debug if enabled begin self.chunks = [] yield ensure flush self.chunks = [] unless preserve end else yield end end |
.flush ⇒ Object
128 129 130 131 132 133 134 135 |
# File 'lib/graphiti/debugger.rb', line 128 def flush Graphiti.broadcast(:flush_debug, {}) do |payload| payload[:chunks] = chunks graph_statements.each do |chunk| flush_chunk(chunk) end end end |
.on_data(name, start, stop, id, payload) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/graphiti/debugger.rb', line 12 def on_data(name, start, stop, id, payload) return [] unless enabled took = ((stop - start) * 1000.0).round(2) params = scrub_params(payload[:params]) if payload[:exception] on_data_exception(payload, params) elsif payload[:sideload] if payload[:results] on_sideload_data(payload, params, took) end else on_primary_data(payload, params, took) end end |
.on_render(name, start, stop, id, payload) ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/graphiti/debugger.rb', line 94 def on_render(name, start, stop, id, payload) return [] unless enabled add_chunk do |logs| took = ((stop - start) * 1000.0).round(2) logs << [""] logs << ["=== Graphiti Debug", :green, true] logs << ["Rendering:", :green, true] logs << ["Took: #{took}ms", :magenta, true] end end |
.to_a ⇒ Object
120 121 122 123 124 125 126 |
# File 'lib/graphiti/debugger.rb', line 120 def to_a debugs = [] graph_statements.each do |chunk| debugs << chunk_to_hash(chunk) end debugs end |