diff options
author | Emilio Tagua <miloops@gmail.com> | 2010-09-22 12:24:55 -0300 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2010-09-22 18:08:04 -0300 |
commit | c88deaf5ee0a7abd767a770ebfbe9ab532b147de (patch) | |
tree | fe5bbde97663ca7a95d6040afd96300cc7fa6a55 /activesupport/lib/active_support/core_ext/object/instance_variables.rb | |
parent | 7047d83ec505fb921f3dc07246a6cfe8f71f6ea6 (diff) | |
download | rails-c88deaf5ee0a7abd767a770ebfbe9ab532b147de.tar.gz rails-c88deaf5ee0a7abd767a770ebfbe9ab532b147de.tar.bz2 rails-c88deaf5ee0a7abd767a770ebfbe9ab532b147de.zip |
Use map, no need to use inject here.
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
Diffstat (limited to 'activesupport/lib/active_support/core_ext/object/instance_variables.rb')
-rw-r--r-- | activesupport/lib/active_support/core_ext/object/instance_variables.rb | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/activesupport/lib/active_support/core_ext/object/instance_variables.rb b/activesupport/lib/active_support/core_ext/object/instance_variables.rb index 97b288c608..77a3cfc21d 100644 --- a/activesupport/lib/active_support/core_ext/object/instance_variables.rb +++ b/activesupport/lib/active_support/core_ext/object/instance_variables.rb @@ -10,10 +10,7 @@ class Object # # C.new(0, 1).instance_values # => {"x" => 0, "y" => 1} def instance_values #:nodoc: - instance_variables.inject({}) do |values, name| - values[name.to_s[1..-1]] = instance_variable_get(name) - values - end + Hash[instance_variables.map { |name| [name.to_s[1..-1], instance_variable_get(name)] }] end # Returns an array of instance variable names including "@". They are strings |