Skip to content

Instantly share code, notes, and snippets.

@dallasmarlow
Created September 21, 2012 21:17
Show Gist options
  • Save dallasmarlow/3763952 to your computer and use it in GitHub Desktop.
Save dallasmarlow/3763952 to your computer and use it in GitHub Desktop.
collect instance variables
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