Module: Oboe::API::Util
- Included in:
- Oboe::API
- Defined in:
- lib/oboe/api/util.rb
Constant Summary collapse
- BACKTRACE_CUTOFF =
100
Instance Method Summary collapse
-
#backtrace(ignore = 1) ⇒ Object
Internal: Get the current backtrace.
-
#valid_key?(key) ⇒ Boolean
Internal: Check whether the provided key is reserved or not.
Instance Method Details
#backtrace(ignore = 1) ⇒ Object
Internal: Get the current backtrace.
ignore - Number of frames to ignore at the end of the backtrace. Use
when you know how many layers deep in oboe the call is being
made.
Returns a string with each frame of the backtrace separated by ‘rn’.
26 27 28 29 30 31 32 33 34 |
# File 'lib/oboe/api/util.rb', line 26 def backtrace(ignore=1) frames = Kernel.caller frames_len = frames.size if frames_len - ignore > BACKTRACE_CUTOFF frames[ignore, BACKTRACE_CUTOFF + ignore].unshift("...") else frames.drop(ignore) end.join("\r\n") end |
#valid_key?(key) ⇒ Boolean
Internal: Check whether the provided key is reserved or not. Reserved keys are either keys that are handled by liboboe calls or the oboe gem.
key - the key to check.
Return a boolean indicating whether or not key is reserved.
15 16 17 |
# File 'lib/oboe/api/util.rb', line 15 def valid_key?(key) !%w[ Label Layer Edge Timestamp Timestamp_u ].include? key.to_s end |