From 5f56d90085ea484b99e080c231c17ddc6cda71d1 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Fri, 6 Feb 2009 10:05:16 -0800 Subject: Use Array.wrap, remove unneeded returning block --- .../lib/active_support/json/encoders/hash.rb | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'activesupport/lib/active_support/json/encoders/hash.rb') 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 -- cgit v1.2.3