Class: BigDecimal

Inherits:
Object
  • Object
show all
Defined in:
lib/json/add/bigdecimal.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.json_create(object) ⇒ Object

Import a JSON Marshalled object.

method used for JSON marshalling support.



14
15
16
# File 'lib/json/add/bigdecimal.rb', line 14

def self.json_create(object)
  BigDecimal._load object['b']
end

Instance Method Details

#as_jsonObject

Marshal the object to JSON.

method used for JSON marshalling support.



21
22
23
24
25
26
# File 'lib/json/add/bigdecimal.rb', line 21

def as_json(*)
  {
    JSON.create_id => self.class.name,
    'b'            => _dump,
  }
end

#to_json(*args) ⇒ Object

return the JSON value



29
30
31
# File 'lib/json/add/bigdecimal.rb', line 29

def to_json(*args)
  as_json.to_json(*args)
end