Module: ProcessMetrics::ClassMethods

Defined in:
lib/process_metrics/timer.rb

Constant Summary collapse

@@replacing =
false

Instance Method Summary collapse

Instance Method Details

#measure(*methods_names) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/process_metrics/timer.rb', line 5

def measure(*methods_names)
  methods_names.flatten!
  options = extract_options(methods_names)

  methods_names.each do |method_name|
    define_wrapper_method(method_name, options)
    wrap_method(method_name) if method_exists?(method_name)
  end
end

#method_added(method_name) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/process_metrics/timer.rb', line 15

def method_added(method_name)
  return if method_name =~ /^measure_/ || method_name =~ /^raw_/
  ProcessMetrics.config.logger.debug "Adding method #{method_name} in #{self}"

  measure_method_name = :"measure_#{method_name}"

  if self.instance_methods.include? measure_method_name
    ProcessMetrics.config.logger.debug "#{self}##{measure_method_name} exists. Wrapping..."
    wrap_method(method_name)
  else
    ProcessMetrics.config.logger.debug "#{self}##{measure_method_name} does not exist. Exiting..."
  end
end