Module: NewRelic::Helper

Extended by:
Helper
Included in:
Helper
Defined in:
lib/new_relic/helper.rb

Overview

A singleton for shared generic helper methods

Instance Method Summary collapse

Instance Method Details

#correctly_encoded(string) ⇒ Object

noop



17
18
19
20
# File 'lib/new_relic/helper.rb', line 17

def correctly_encoded(string)
  return string unless string.is_a? String
  string.valid_encoding? ? string : string.force_encoding("ASCII-8BIT")
end

#instance_method_visibility(klass, method_name) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/new_relic/helper.rb', line 22

def instance_method_visibility(klass, method_name)
  if klass.private_instance_methods.map{|s|s.to_sym}.include? method_name.to_sym
    :private
  elsif klass.protected_instance_methods.map{|s|s.to_sym}.include? method_name.to_sym
    :protected
  else
    :public
  end
end

#time_to_millis(time) ⇒ Object



32
33
34
# File 'lib/new_relic/helper.rb', line 32

def time_to_millis(time)
  (time.to_f * 1000).round
end