Created
November 4, 2009 02:23
-
-
Save taelor/225709 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def strip_ids(array) | |
array.each{ |row| row.reject! {|k, v| k =~ /_id/ } } | |
end | |
class Foo | |
attr_accessor :array | |
def initialize | |
@array = [] | |
@array << { :some_id => 1, :something => 'one' } | |
@array << { :some_id => 2, :something => 'two' } | |
@array << { :some_id => 3, :something => 'three'} | |
end | |
end | |
foo = Foo.new | |
puts strip_ids(foo.array).inspect | |
puts foo.array.inspect | |
########################## | |
# | |
# Output in ruby 1.8.7 | |
# | |
# [{:some_id=>1, :something=>"one"}, {:some_id=>2, :something=>"two"}, {:some_id=>3, :something=>"three"}] | |
# | |
# | |
# Output in ruby 1.9.1 | |
# | |
# [{:something=>"one"}, {:something=>"two"}, {:something=>"three"}] | |
# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment