Sha256: 73ea301c7a3d6e6b4e22b5d4b6e7996b401954236ab5bd9e97e088767677f010

Contents?: true

Size: 1.24 KB

Versions: 14

Compression:

Stored size: 1.24 KB

Contents

module Instana
  module Util
    ##
    # enforce_deltas
    #
    # Take two hashes, and make sure candidate does not have
    # any of the same values as `last`.  We only report
    # when values change.
    #
    # Note this is not recursive, so only pass in the single
    # hashes that you want delta reporting with.
    #
    def self.enforce_deltas(candidate, last)
      return unless last.is_a?(Hash)

      candidate.each do |k,v|
        if candidate[k] == last[k]
          candidate.delete(k)
        end
      end
      candidate
    end
  end

  ##
  # Debugging helper method
  #
  def self.pry!
    # Only valid for development or test environments
    #env = ENV['RACK_ENV'] || ENV['RAILS_ENV']
    #return unless %w(development, test).include? env

    if RUBY_VERSION > '1.8.7'
      require 'pry-byebug'

      if defined?(PryByebug)
        Pry.commands.alias_command 'c', 'continue'
        Pry.commands.alias_command 's', 'step'
        Pry.commands.alias_command 'n', 'next'
        Pry.commands.alias_command 'f', 'finish'

        Pry::Commands.command(/^$/, 'repeat last command') do
          _pry_.run_command Pry.history.to_a.last
        end
      end

      binding.pry
    else
      require 'ruby-debug'; debugger
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
instana-0.12.1 lib/instana/util.rb
instana-0.12.0 lib/instana/util.rb
instana-0.11.0 lib/instana/util.rb
instana-0.10.1 lib/instana/util.rb
instana-0.9.2 lib/instana/util.rb
instana-0.9.1 lib/instana/util.rb
instana-0.9.0 lib/instana/util.rb
instana-0.9.0.pre.slywolf3 lib/instana/util.rb
instana-0.8.6 lib/instana/util.rb
instana-0.8.4 lib/instana/util.rb
instana-0.8.3 lib/instana/util.rb
instana-0.8.2 lib/instana/util.rb
instana-0.8.1 lib/instana/util.rb
instana-0.8.beta1 lib/instana/util.rb