Permalink
Browse files

Updated mongo_mapper.

This version implements saner associations and ActiveModel::Validations
  • Loading branch information...
1 parent 7feec35 commit c361a5d6f7cff6e49d6c7f53c29a53e4d1e2ad0d @ml committed Mar 3, 2011
Showing with 8 additions and 6 deletions.
  1. +2 −2 Gemfile
  2. +6 −4 lib/veneer/adapters/mongomapper/class_wrapper.rb
View
@@ -6,11 +6,11 @@ gemspec
gem 'rake'
gem 'shoulda'
gem 'activerecord'
-gem 'mongo_mapper'
+gem 'mongo_mapper', :git => "https://github.com/jnunemaker/mongomapper.git"
gem 'dm-core'
gem 'dm-migrations'
gem 'dm-validations'
gem 'dm-aggregates'
gem 'dm-sqlite-adapter'
gem 'sqlite3-ruby'
-gem 'mysql2'
+gem 'mysql2'
@@ -2,6 +2,8 @@ module MongoMapper
module Document
module VeneerInterface
class ClassWrapper < Veneer::Base::ClassWrapper
+ delegate :validators_on, :to => :klass
+
PRIMARY_KEYS = [:_id]
def self.model_classes
@@ -14,9 +16,8 @@ def new(opts = {})
def collection_associations
@collection_associations ||= begin
- types = [:many]
klass.associations.inject([]) do |ary, (name, assoc)|
- if types.include?(assoc.type)
+ if assoc.is_a? ::MongoMapper::Plugins::Associations::ManyAssociation
ary << {
:name => name,
:class => assoc.class_name.constantize
@@ -29,9 +30,10 @@ def collection_associations
def member_associations
@member_associations ||= begin
- types = [:belongs_to, :one]
+ types = [::MongoMapper::Plugins::Associations::BelongsToAssociation,
+ ::MongoMapper::Plugins::Associations::ManyAssociation]
klass.associations.inject([]) do |ary, (name, assoc)|
- if types.include?(assoc.type)
+ if types.include?(assoc.class)
ary << {
:name => name,
:class => assoc.class_name.constantize

0 comments on commit c361a5d

Please sign in to comment.