summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/json/add/bigdecimal.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/json/add/bigdecimal.rb b/lib/json/add/bigdecimal.rb
index 4aafe53..0ef69f1 100644
--- a/lib/json/add/bigdecimal.rb
+++ b/lib/json/add/bigdecimal.rb
@@ -4,10 +4,16 @@ 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,
@@ -15,6 +21,7 @@ class BigDecimal
}
end
+ # return the JSON value
def to_json(*)
as_json.to_json
end