Module: Tenacity::OrmExt::MongoMapper
- Defined in:
- lib/tenacity/orm_ext/mongo_mapper.rb
Overview
Tenacity relationships on MongoMapper objects require no special keys defined on the object. Tenacity will define the keys that it needs to support the relationships. Take the following class for example:
class Car
include MongoMapper::Document
include Tenacity
t_has_many :wheels
t_has_one :dashboard
t_belongs_to :driver
end
t_belongs_to
The t_belongs_to association will define a key named after the association. The example above will create a key named :driver_id
t_has_one
The t_has_one association will not define any new keys on the object, since the associated object holds the foreign key.
t_has_many
The t_has_many association will define a key named after the association. The example above will create a key named :wheels_ids
Defined Under Namespace
Modules: ClassMethods, InstanceMethods
Class Method Summary collapse
-
.setup(model) ⇒ Object
:nodoc:.
Class Method Details
.setup(model) ⇒ Object
:nodoc:
35 36 37 38 39 40 41 42 43 |
# File 'lib/tenacity/orm_ext/mongo_mapper.rb', line 35 def self.setup(model) #:nodoc: require 'mongo_mapper' if model.included_modules.include?(::MongoMapper::Document) model.send :include, MongoMapper::InstanceMethods model.extend MongoMapper::ClassMethods end rescue LoadError # MongoMapper not available end |