Sha256: 8684510fbf753d544c11a2935005cb4d51113bce94133e6128eecf691b8d6941

Contents?: true

Size: 925 Bytes

Versions: 5

Compression:

Stored size: 925 Bytes

Contents

Rollbar.plugins.define('basic_socket') do
  load_on_demand

  dependency { !configuration.disable_core_monkey_patch }

  # Needed to avoid active_support (< 4.1.0) bug serializing JSONs
  dependency do
    defined?(ActiveSupport::VERSION::STRING) &&
      Gem::Version.new(ActiveSupport::VERSION::STRING) < Gem::Version.new('5.2.0')
  end

  execute do
    class BasicSocket # :nodoc:
      def new_as_json(_options = nil)
        {
          :value => inspect
        }
      end
      # alias_method is recommended over alias when aliasing at runtime.
      # https://github.com/rubocop-hq/ruby-style-guide#alias-method
      alias_method :original_as_json, :as_json # rubocop:disable Style/Alias
      alias_method :as_json, :new_as_json # rubocop:disable Style/Alias
    end
  end

  revert do
    class BasicSocket # :nodoc:
      alias_method :as_json, :original_as_json # rubocop:disable Style/Alias
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rollbar-2.20.2 lib/rollbar/plugins/basic_socket.rb
rollbar-2.20.1 lib/rollbar/plugins/basic_socket.rb
rollbar-2.20.0 lib/rollbar/plugins/basic_socket.rb
rollbar-2.19.4 lib/rollbar/plugins/basic_socket.rb
rollbar-2.19.3 lib/rollbar/plugins/basic_socket.rb