jnunemaker/mongomapper — Issue #327: SingletonClass and MongoMapper
Author: phiny
Created: 2011-10-20 01:22:50+00:00
State: open

I dont know very much about MongoMapper, but... I try open one object and put more attributes and I had this problem:

My class arealy have the @keys hash then MongoMapper returns only on my class hash and dont look the hash of my SingletonClass... then attr_acessor created by MongoMapper, validates and etc dont work for attributes that I add for my object.

I overwrite the keys method like this:

def keys
@keys ||= {}
@keys = @keys.merge(self.singleton_class.keys) if self.singleton_class.respond_to? :keys
@keys
end

Works fine for me, but i dont know if this is the better solution.