Sha256: ea334a93e009fe798ace96ed85f682c0858dc3d4441ce2e8d4f45001e3ff91de

Contents?: true

Size: 893 Bytes

Versions: 21

Compression:

Stored size: 893 Bytes

Contents

module NewRelic
  # A singleton for shared generic helper methods
  module Helper
    extend self

    # confirm a string is correctly encoded (in >= 1.9)
    # If not force the encoding to ASCII-8BIT (binary)
    if RUBY_VERSION >= '1.9'
      def correctly_encoded(string)
        return string unless string.is_a? String
        string.valid_encoding? ? string : string.force_encoding("ASCII-8BIT")
      end
    else
      #noop
      def correctly_encoded(string)
        string
      end
    end

    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

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

Version data entries

21 entries across 21 versions & 3 rubygems

Version Path
newrelic_rpm-3.5.7.59 lib/new_relic/helper.rb
newrelic_rpm-3.5.7.59.beta lib/new_relic/helper.rb
newrelic_rpm-3.5.7.58.beta lib/new_relic/helper.rb
wd_newrelic_rpm-3.5.6 lib/new_relic/helper.rb
newrelic_rpm-3.5.7.57.beta lib/new_relic/helper.rb
newrelic_rpm-3.5.6.55 lib/new_relic/helper.rb
newrelic_rpm-3.5.6.48.beta lib/new_relic/helper.rb
newrelic_rpm-3.5.6.46.beta lib/new_relic/helper.rb
newrelic_rpm-3.5.6.42.beta lib/new_relic/helper.rb
newrelic_rpm-3.5.5.39.beta lib/new_relic/helper.rb
wd_newrelic_rpm-3.5.5 lib/new_relic/helper.rb
newrelic_rpm-3.5.5.38 lib/new_relic/helper.rb
newrelic_rpm-3.5.5.540.dev lib/new_relic/helper.rb
newrelic_rpm-3.5.4.35.beta lib/new_relic/helper.rb
newrelic_rpm-3.5.4.34 lib/new_relic/helper.rb
newrelic_rpm-3.5.4.33 lib/new_relic/helper.rb
newrelic_rpm-3.5.4.31.beta lib/new_relic/helper.rb
newrelic_rpm-3.5.4.29.beta lib/new_relic/helper.rb
ghazel-newrelic_rpm-3.5.4 lib/new_relic/helper.rb
newrelic_rpm-3.5.3.25 lib/new_relic/helper.rb