Method: MongoMapper::Plugins::Keys::InstanceMethods#attributes
- Defined in:
- lib/novelys_mongo_mapper/plugins/keys.rb
#attributes ⇒ Object Also known as: to_mongo
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 |
# File 'lib/novelys_mongo_mapper/plugins/keys.rb', line 179 def attributes attrs = HashWithIndifferentAccess.new keys.each_pair do |name, key| value = key.set(self[key.name]) attrs[name] = value end .each do |association| if documents = instance_variable_get(association.ivar) attrs[association.name] = documents.map { |document| document.to_mongo } end end attrs end |