Sha256: b9bfa1a8e2f172a7d366c1011775bfb01827cdc177f2b008c7f65caad7c574cb

Contents?: true

Size: 609 Bytes

Versions: 139

Compression:

Stored size: 609 Bytes

Contents

#frozen_string_literal: false
unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
  require 'json'
end
defined?(::BigDecimal) or require 'bigdecimal'

class BigDecimal
  # Import a JSON Marshalled object.
  #
  # method used for JSON marshalling support.
  def self.json_create(object)
    BigDecimal._load object['b']
  end

  # Marshal the object to JSON.
  #
  # method used for JSON marshalling support.
  def as_json(*)
    {
      JSON.create_id => self.class.name,
      'b'            => _dump,
    }
  end

  # return the JSON value
  def to_json(*args)
    as_json.to_json(*args)
  end
end

Version data entries

139 entries across 129 versions & 18 rubygems

Version Path
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/json-2.3.1/lib/json/add/bigdecimal.rb
cloudsmith-api-0.52.121 vendor/bundle/ruby/2.6.0/gems/json-2.3.1/lib/json/add/bigdecimal.rb
cloudsmith-api-0.52.92 vendor/bundle/ruby/2.6.0/gems/json-2.3.1/lib/json/add/bigdecimal.rb
logstash-filter-csharp-0.2.1 vendor/bundle/jruby/2.5.0/gems/json-2.3.1-java/lib/json/add/bigdecimal.rb
logstash-filter-csharp-0.2.0 vendor/bundle/jruby/2.5.0/gems/json-2.3.1-java/lib/json/add/bigdecimal.rb
cloudsmith-api-0.52.79 vendor/bundle/ruby/2.6.0/gems/json-2.3.1/lib/json/add/bigdecimal.rb
tdiary-5.1.3 vendor/bundle/ruby/2.6.0/gems/json-2.3.0/lib/json/add/bigdecimal.rb
tdiary-5.1.3 vendor/bundle/ruby/2.7.0/gems/json-2.3.1/lib/json/add/bigdecimal.rb
video_chat_get-0.1.5 vendor/bundle/ruby/2.5.0/gems/json-2.3.0/lib/json/add/bigdecimal.rb
video_chat_get-0.1.5 vendor/bundle/ruby/2.5.0/gems/json-2.3.0/lib/json/add/bigdecimal 2.rb
video_chat_get-0.1.4 vendor/bundle/ruby/2.5.0/gems/json-2.3.0/lib/json/add/bigdecimal.rb
video_chat_get-0.1.3 vendor/bundle/ruby/2.5.0/gems/json-2.3.0/lib/json/add/bigdecimal.rb
video_chat_get-0.1.2 vendor/bundle/ruby/2.5.0/gems/json-2.3.0/lib/json/add/bigdecimal.rb
cli-nasa-0.1.1 vendor/bundle/ruby/2.7.0/gems/json-2.3.1/lib/json/add/bigdecimal.rb
cli-nasa-0.1.0 vendor/bundle/ruby/2.7.0/gems/json-2.3.1/lib/json/add/bigdecimal.rb
cloudsmith-api-0.52.5 vendor/bundle/ruby/2.6.0/gems/json-2.3.1/lib/json/add/bigdecimal.rb
video_chat_get-0.1.1 vendor/bundle/ruby/2.5.0/gems/json-2.3.0/lib/json/add/bigdecimal.rb
video_chat_get-0.1.0 vendor/bundle/ruby/2.5.0/gems/json-2.3.0/lib/json/add/bigdecimal.rb
cloudsmith-api-0.52.0 vendor/bundle/ruby/2.6.0/gems/json-2.3.1/lib/json/add/bigdecimal.rb
cloudsmith-api-0.51.93 vendor/bundle/ruby/2.3.0/gems/json-2.3.1/lib/json/add/bigdecimal.rb