Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

move reflect_on_association to Rails module

  • Loading branch information...
commit 3d633a23b47d78bcd740cadd9027a6211378b65e 1 parent f589066
@balexand balexand authored
View
61 lib/mongo_mapper.rb
@@ -26,37 +26,36 @@ module Middleware
end
module Plugins
- autoload :ActiveModel, 'mongo_mapper/plugins/active_model'
- autoload :Associations, 'mongo_mapper/plugins/associations'
- autoload :Accessible, 'mongo_mapper/plugins/accessible'
- autoload :Callbacks, 'mongo_mapper/plugins/callbacks'
- autoload :Caching, 'mongo_mapper/plugins/caching'
- autoload :Clone, 'mongo_mapper/plugins/clone'
- autoload :Dirty, 'mongo_mapper/plugins/dirty'
- autoload :Document, 'mongo_mapper/plugins/document'
- autoload :DynamicQuerying, 'mongo_mapper/plugins/dynamic_querying'
- autoload :EmbeddedCallbacks, 'mongo_mapper/plugins/embedded_callbacks'
- autoload :EmbeddedDocument, 'mongo_mapper/plugins/embedded_document'
- autoload :Equality, 'mongo_mapper/plugins/equality'
- autoload :IdentityMap, 'mongo_mapper/plugins/identity_map'
- autoload :Inspect, 'mongo_mapper/plugins/inspect'
- autoload :Indexes, 'mongo_mapper/plugins/indexes'
- autoload :Keys, 'mongo_mapper/plugins/keys'
- autoload :Logger, 'mongo_mapper/plugins/logger'
- autoload :Modifiers, 'mongo_mapper/plugins/modifiers'
- autoload :Pagination, 'mongo_mapper/plugins/pagination'
- autoload :Persistence, 'mongo_mapper/plugins/persistence'
- autoload :Protected, 'mongo_mapper/plugins/protected'
- autoload :Querying, 'mongo_mapper/plugins/querying'
- autoload :Rails, 'mongo_mapper/plugins/rails'
- autoload :ReflectOnAssociation, 'mongo_mapper/plugins/reflect_on_association'
- autoload :Safe, 'mongo_mapper/plugins/safe'
- autoload :Sci, 'mongo_mapper/plugins/sci'
- autoload :Scopes, 'mongo_mapper/plugins/scopes'
- autoload :Serialization, 'mongo_mapper/plugins/serialization'
- autoload :Timestamps, 'mongo_mapper/plugins/timestamps'
- autoload :Userstamps, 'mongo_mapper/plugins/userstamps'
- autoload :Validations, 'mongo_mapper/plugins/validations'
+ autoload :ActiveModel, 'mongo_mapper/plugins/active_model'
+ autoload :Associations, 'mongo_mapper/plugins/associations'
+ autoload :Accessible, 'mongo_mapper/plugins/accessible'
+ autoload :Callbacks, 'mongo_mapper/plugins/callbacks'
+ autoload :Caching, 'mongo_mapper/plugins/caching'
+ autoload :Clone, 'mongo_mapper/plugins/clone'
+ autoload :Dirty, 'mongo_mapper/plugins/dirty'
+ autoload :Document, 'mongo_mapper/plugins/document'
+ autoload :DynamicQuerying, 'mongo_mapper/plugins/dynamic_querying'
+ autoload :EmbeddedCallbacks, 'mongo_mapper/plugins/embedded_callbacks'
+ autoload :EmbeddedDocument, 'mongo_mapper/plugins/embedded_document'
+ autoload :Equality, 'mongo_mapper/plugins/equality'
+ autoload :IdentityMap, 'mongo_mapper/plugins/identity_map'
+ autoload :Inspect, 'mongo_mapper/plugins/inspect'
+ autoload :Indexes, 'mongo_mapper/plugins/indexes'
+ autoload :Keys, 'mongo_mapper/plugins/keys'
+ autoload :Logger, 'mongo_mapper/plugins/logger'
+ autoload :Modifiers, 'mongo_mapper/plugins/modifiers'
+ autoload :Pagination, 'mongo_mapper/plugins/pagination'
+ autoload :Persistence, 'mongo_mapper/plugins/persistence'
+ autoload :Protected, 'mongo_mapper/plugins/protected'
+ autoload :Querying, 'mongo_mapper/plugins/querying'
+ autoload :Rails, 'mongo_mapper/plugins/rails'
+ autoload :Safe, 'mongo_mapper/plugins/safe'
+ autoload :Sci, 'mongo_mapper/plugins/sci'
+ autoload :Scopes, 'mongo_mapper/plugins/scopes'
+ autoload :Serialization, 'mongo_mapper/plugins/serialization'
+ autoload :Timestamps, 'mongo_mapper/plugins/timestamps'
+ autoload :Userstamps, 'mongo_mapper/plugins/userstamps'
+ autoload :Validations, 'mongo_mapper/plugins/validations'
module Associations
autoload :Base, 'mongo_mapper/plugins/associations/base'
View
1  lib/mongo_mapper/document.rb
@@ -23,7 +23,6 @@ module Document
include Plugins::Accessible
include Plugins::Protected
include Plugins::Rails
- include Plugins::ReflectOnAssociation
include Plugins::Safe # needs to be after querying (save_to_collection)
include Plugins::Sci
include Plugins::Scopes
View
1  lib/mongo_mapper/embedded_document.rb
@@ -17,7 +17,6 @@ module EmbeddedDocument
include Plugins::Accessible
include Plugins::Protected
include Plugins::Rails
- include Plugins::ReflectOnAssociation
include Plugins::Sci
include Plugins::Serialization
include Plugins::Validations
View
8 lib/mongo_mapper/plugins/rails.rb
@@ -2,6 +2,7 @@
module MongoMapper
module Plugins
module Rails
+ autoload :ActiveRecordAssociationAdapter, "mongo_mapper/plugins/rails/active_record_association_adapter"
extend ActiveSupport::Concern
module InstanceMethods
@@ -46,6 +47,13 @@ def has_many(*args, &extension)
def column_names
keys.keys
end
+
+ # Returns returns an ActiveRecordAssociationAdapter for an association. This adapter has an API that is a
+ # subset of ActiveRecord::Reflection::AssociationReflection. This allows MongoMapper to be used with the
+ # association helpers in gems like simple_form and formtastic.
+ def reflect_on_association(name)
+ ActiveRecordAssociationAdapter.for_association(associations[name]) if associations[name]
+ end
end
end
end
View
2  ...tion/active_record_association_adapter.rb → ...ails/active_record_association_adapter.rb
@@ -1,7 +1,7 @@
# encoding: UTF-8
module MongoMapper
module Plugins
- module ReflectOnAssociation
+ module Rails
class ActiveRecordAssociationAdapter
attr_reader :klass, :macro, :name, :options
View
19 lib/mongo_mapper/plugins/reflect_on_association.rb
@@ -1,19 +0,0 @@
-# encoding: UTF-8
-require 'mongo_mapper/plugins/reflect_on_association/active_record_association_adapter'
-
-module MongoMapper
- module Plugins
- # Provides a reflect_on_association method that returns an ActiveRecordAssociationAdapter for an association.
- # This adapter has an API that is a subset of ActiveRecord::Reflection::AssociationReflection. This allows
- # MongoMapper to be used with the association helpers in gems like simple_form and formtastic.
- module ReflectOnAssociation
- extend ActiveSupport::Concern
-
- module ClassMethods
- def reflect_on_association(name)
- ActiveRecordAssociationAdapter.for_association(associations[name]) if associations[name]
- end
- end
- end
- end
-end
Please sign in to comment.
Something went wrong with that request. Please try again.