Permalink
Browse files

BigDecimal Documentation

  • Loading branch information...
1 parent 86128f5 commit 97d2d8deee6940e57c26ea68a884dfa1b84fcb15 @zzak zzak committed Nov 9, 2012
Showing with 7 additions and 0 deletions.
  1. +7 −0 lib/json/add/bigdecimal.rb
View
7 lib/json/add/bigdecimal.rb
@@ -4,17 +4,24 @@
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(*)
as_json.to_json
end

0 comments on commit 97d2d8d

Please sign in to comment.