aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2009-02-06 10:05:16 -0800
committerJeremy Kemper <jeremy@bitsweat.net>2009-02-06 10:05:16 -0800
commit5f56d90085ea484b99e080c231c17ddc6cda71d1 (patch)
treea5428de79c8d4d385d5a14f908327f94fe44a5f3 /activesupport
parent676b0c87642786080ab9e22fcc86a13d15324d4b (diff)
downloadrails-5f56d90085ea484b99e080c231c17ddc6cda71d1.tar.gz
rails-5f56d90085ea484b99e080c231c17ddc6cda71d1.tar.bz2
rails-5f56d90085ea484b99e080c231c17ddc6cda71d1.zip
Use Array.wrap, remove unneeded returning block
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/json/encoders/hash.rb19
1 files changed, 9 insertions, 10 deletions
diff --git a/activesupport/lib/active_support/json/encoders/hash.rb b/activesupport/lib/active_support/json/encoders/hash.rb
index 16dc8337f5..e38b4f3e16 100644
--- a/activesupport/lib/active_support/json/encoders/hash.rb
+++ b/activesupport/lib/active_support/json/encoders/hash.rb
@@ -31,17 +31,16 @@ class Hash
def to_json(options = {}) #:nodoc:
hash_keys = self.keys
- if options[:except]
- hash_keys = hash_keys - Array(options[:except])
- elsif options[:only]
- hash_keys = hash_keys & Array(options[:only])
+ if except = options[:except]
+ hash_keys = hash_keys - Array.wrap(except)
+ elsif only = options[:only]
+ hash_keys = hash_keys & Array.wrap(only)
end
- returning result = '{' do
- result << hash_keys.map do |key|
- "#{ActiveSupport::JSON.encode(key.to_s)}: #{ActiveSupport::JSON.encode(self[key], options)}"
- end * ', '
- result << '}'
- end
+ result = '{'
+ result << hash_keys.map do |key|
+ "#{ActiveSupport::JSON.encode(key.to_s)}: #{ActiveSupport::JSON.encode(self[key], options)}"
+ end * ', '
+ result << '}'
end
end