Skip to content

Instantly share code, notes, and snippets.

@DanielVartanov
Created January 19, 2013 06:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DanielVartanov/4570992 to your computer and use it in GitHub Desktop.
Save DanielVartanov/4570992 to your computer and use it in GitHub Desktop.
require 'mongoid'
class Item; include Mongoid::Document; end
def clean_object(obj)
obj.instance_variables.each do |ivar|
obj.send(:remove_instance_variable, ivar) unless ivar == :@attributes
end
end
item = Item.new
clean_object(Item.new)
item.instance_variables # => [:@attributes]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment