Fixing as_json to always use a simple Hash and remove nils. History updates.

This commit is contained in:
Sam Lown 2011-05-19 00:08:58 +02:00
parent a284c65992
commit 1ef25c5015
3 changed files with 33 additions and 0 deletions

View file

@ -12,6 +12,10 @@ module CouchRest
raise "You can only mixin Properties in a class responding to [] and []=, if you tried to mixin CastedModel, make sure your class inherits from Hash or responds to the proper methods" unless (method_defined?(:[]) && method_defined?(:[]=))
end
def as_json(options = nil)
Hash[self].reject{|k,v| v.nil?}.as_json(options)
end
# Returns the Class properties
#
# ==== Returns