Created
September 21, 2012 21:17
-
-
Save dallasmarlow/3763952 to your computer and use it in GitHub Desktop.
collect instance variables
This file contains hidden or 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 collect_instance_variables object | |
values = object.instance_variables.collect do |variable| | |
object.instance_variable_get variable.to_s | |
end | |
Hash[object.instance_variables.zip(values)] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment