aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/json/encoders/hash.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2009-04-26 15:18:33 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2009-04-26 15:18:33 -0700
commit8d64085138b1a2ff36b94267d0236868b287610e (patch)
tree928eba809df85dfe47195f05171d60af3dec6665 /activesupport/lib/active_support/json/encoders/hash.rb
parentbe7e21a85c487b6f3bfc2e393387ada5cc52290d (diff)
downloadrails-8d64085138b1a2ff36b94267d0236868b287610e.tar.gz
rails-8d64085138b1a2ff36b94267d0236868b287610e.tar.bz2
rails-8d64085138b1a2ff36b94267d0236868b287610e.zip
Only Object to_json alias is needed. Prefer nil options.
Diffstat (limited to 'activesupport/lib/active_support/json/encoders/hash.rb')
-rw-r--r--activesupport/lib/active_support/json/encoders/hash.rb14
1 files changed, 7 insertions, 7 deletions
diff --git a/activesupport/lib/active_support/json/encoders/hash.rb b/activesupport/lib/active_support/json/encoders/hash.rb
index 19b97d7b8c..cd8639c1dd 100644
--- a/activesupport/lib/active_support/json/encoders/hash.rb
+++ b/activesupport/lib/active_support/json/encoders/hash.rb
@@ -30,13 +30,15 @@ class Hash
# would pass the <tt>:include => :posts</tt> option to <tt>users</tt>,
# allowing the posts association in the User model to be converted to JSON
# as well.
- def rails_to_json(options = {}) #:nodoc:
+ def rails_to_json(options = nil) #:nodoc:
hash_keys = self.keys
- if except = options[:except]
- hash_keys = hash_keys - Array.wrap(except)
- elsif only = options[:only]
- hash_keys = hash_keys & Array.wrap(only)
+ if options
+ if except = options[:except]
+ hash_keys = hash_keys - Array.wrap(except)
+ elsif only = options[:only]
+ hash_keys = hash_keys & Array.wrap(only)
+ end
end
result = '{'
@@ -45,6 +47,4 @@ class Hash
end * ','
result << '}'
end
-
- alias to_json rails_to_json
end