public
Created

  • Download Gist
gistfile1.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13
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]

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.