Module: Bugsage::ConsoleContext
- Defined in:
- lib/bugsage/console_context.rb
Class Method Summary collapse
- .available? ⇒ Boolean
- .binding_for_eval ⇒ Object
- .clear! ⇒ Object
- .load_from_event(event) ⇒ Object
- .safe_constantize(name) ⇒ Object
- .set(exception:, context:) ⇒ Object
Class Method Details
.available? ⇒ Boolean
39 40 41 |
# File 'lib/bugsage/console_context.rb', line 39 def available? !@exception.nil? end |
.binding_for_eval ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/bugsage/console_context.rb', line 31 def binding_for_eval exception = @exception request_context = @context || {} params = request_context["Request parameters"] || request_context["Path parameters"] || {} binding end |
.clear! ⇒ Object
26 27 28 29 |
# File 'lib/bugsage/console_context.rb', line 26 def clear! @exception = nil @context = {} end |
.load_from_event(event) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/bugsage/console_context.rb', line 12 def load_from_event(event) return false unless event klass = safe_constantize(event[:exception_class]) = event[:exception_message].to_s = event[:root_cause].to_s if .empty? set( exception: klass.new(), context: event[:context] || {} ) true end |
.safe_constantize(name) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/bugsage/console_context.rb', line 43 def safe_constantize(name) return StandardError if name.to_s.strip.empty? Object.const_get(name) rescue NameError StandardError end |
.set(exception:, context:) ⇒ Object
7 8 9 10 |
# File 'lib/bugsage/console_context.rb', line 7 def set(exception:, context:) @exception = exception @context = context || {} end |