Module: InstrumentAllTheThings::Helpers::ClassMethods

Defined in:
lib/instrument_all_the_things/helpers.rb

Instance Method Summary collapse

Instance Method Details

#_conscript_last_iatt_settingsObject



13
14
15
# File 'lib/instrument_all_the_things/helpers.rb', line 13

def _conscript_last_iatt_settings
  @last_settings.tap { @last_settings = nil }
end

#instrument(**kwargs) ⇒ Object



9
10
11
# File 'lib/instrument_all_the_things/helpers.rb', line 9

def instrument(**kwargs)
  @last_settings = kwargs
end

#method_added(method_name) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/instrument_all_the_things/helpers.rb', line 33

def method_added(method_name)
  settings = _conscript_last_iatt_settings

  return unless settings

  settings[:context] = Context.new(
    method_name: method_name,
    instance: true,
  )

  InstrumentAllTheThings::MethodProxy
    .for_class(self)
    .wrap_implementation(method_name, settings)

  super
end

#singleton_method_added(method_name) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/instrument_all_the_things/helpers.rb', line 17

def singleton_method_added(method_name)
  settings = _conscript_last_iatt_settings

  return unless settings

  settings[:context] = Context.new(
    method_name: method_name,
    instance: false,
  )

  InstrumentAllTheThings::MethodProxy
    .for_class(singleton_class)
    .wrap_implementation(method_name, settings)
  super
end