Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use Array.wrap, remove unneeded returning block

  • Loading branch information...
commit 5f56d90085ea484b99e080c231c17ddc6cda71d1 1 parent 676b0c8
@jeremy jeremy authored
Showing with 9 additions and 10 deletions.
  1. +9 −10 activesupport/lib/active_support/json/encoders/hash.rb
View
19 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
Please sign in to comment.
Something went wrong with that request. Please try again.