Class: HyperTrace::Config
- Inherits:
-
Object
- Object
- HyperTrace::Config
- Defined in:
- lib/hyper_trace/hyper_trace.rb
Instance Attribute Summary collapse
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
Instance Method Summary collapse
- #[](opt) ⇒ Object
- #break_on_enter(methods) ⇒ Object (also: #break_on_entry, #break_on_entry?)
- #break_on_enter?(method, &block) ⇒ Boolean
- #break_on_exit(methods) ⇒ Object
- #break_on_exit?(method, &block) ⇒ Boolean
- #hypertrace_class_exclusions ⇒ Object
- #hypertrace_exclusions ⇒ Object
-
#initialize(klass, instrument_class, opts, &block) ⇒ Config
constructor
A new instance of Config.
- #instrument(opt) ⇒ Object
- #instrument_class? ⇒ Boolean
Constructor Details
#initialize(klass, instrument_class, opts, &block) ⇒ Config
Returns a new instance of Config.
21 22 23 24 25 26 27 28 29 |
# File 'lib/hyper_trace/hyper_trace.rb', line 21 def initialize(klass, instrument_class, opts, &block) @klass = klass @opts = {} @instrument_class = instrument_class [:break_on_enter?, :break_on_entry?, :break_on_exit?, :break_on_enter, :break_on_entry, :break_on_exit, :instrument].each do |method| send(method, opts[method]) if opts[method] end unless opts[:instrument] == :none instance_eval(&block) if block end |
Instance Attribute Details
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
33 34 35 |
# File 'lib/hyper_trace/hyper_trace.rb', line 33 def klass @klass end |
Instance Method Details
#[](opt) ⇒ Object
60 61 62 |
# File 'lib/hyper_trace/hyper_trace.rb', line 60 def [](opt) @opts[opt] end |
#break_on_enter(methods) ⇒ Object Also known as: break_on_entry, break_on_entry?
45 46 47 |
# File 'lib/hyper_trace/hyper_trace.rb', line 45 def break_on_enter(methods) [*methods].each { |method| break_on_enter?(method) { true } } end |
#break_on_enter?(method, &block) ⇒ Boolean
54 55 56 57 58 |
# File 'lib/hyper_trace/hyper_trace.rb', line 54 def break_on_enter?(method, &block) @opts[:break_on_enter?] ||= {} @opts[:break_on_enter?][method] = block instrument(method) end |
#break_on_exit(methods) ⇒ Object
42 43 44 |
# File 'lib/hyper_trace/hyper_trace.rb', line 42 def break_on_exit(methods) [*methods].each { |method| break_on_exit?(method) { true } } end |
#break_on_exit?(method, &block) ⇒ Boolean
49 50 51 52 53 |
# File 'lib/hyper_trace/hyper_trace.rb', line 49 def break_on_exit?(method, &block) @opts[:break_on_exit?] ||= {} @opts[:break_on_exit?][method] = block instrument(method) end |
#hypertrace_class_exclusions ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/hyper_trace/hyper_trace.rb', line 63 def hypertrace_class_exclusions if klass.respond_to? :hypertrace_class_exclusions klass.hypertrace_class_exclusions else [] end end |
#hypertrace_exclusions ⇒ Object
70 71 72 73 74 75 76 |
# File 'lib/hyper_trace/hyper_trace.rb', line 70 def hypertrace_exclusions if klass.respond_to? :hypertrace_exclusions klass.hypertrace_exclusions else [] end end |
#instrument(opt) ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/hyper_trace/hyper_trace.rb', line 34 def instrument(opt) return if @opts[:instrument] == :all if opt == :all @opts[:instrument] = :all else @opts[:instrument] = [*opt, *@opts[:instrument]] end end |
#instrument_class? ⇒ Boolean
30 31 32 |
# File 'lib/hyper_trace/hyper_trace.rb', line 30 def instrument_class? @instrument_class end |