Class: MongoMapper::Plugins::Rails::ActiveRecordAssociationAdapter
- Defined in:
- lib/mongo_mapper/plugins/rails/active_record_association_adapter.rb
Instance Attribute Summary collapse
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
-
#macro ⇒ Object
readonly
Returns the value of attribute macro.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(association, macro) ⇒ ActiveRecordAssociationAdapter
constructor
A new instance of ActiveRecordAssociationAdapter.
Constructor Details
#initialize(association, macro) ⇒ ActiveRecordAssociationAdapter
Returns a new instance of ActiveRecordAssociationAdapter.
23 24 25 26 27 28 29 |
# File 'lib/mongo_mapper/plugins/rails/active_record_association_adapter.rb', line 23 def initialize(association, macro) @klass, @name = association.klass, association.name # only include compatible options @options = association..slice(:conditions, :order) @macro = macro end |
Instance Attribute Details
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
6 7 8 |
# File 'lib/mongo_mapper/plugins/rails/active_record_association_adapter.rb', line 6 def klass @klass end |
#macro ⇒ Object (readonly)
Returns the value of attribute macro.
6 7 8 |
# File 'lib/mongo_mapper/plugins/rails/active_record_association_adapter.rb', line 6 def macro @macro end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/mongo_mapper/plugins/rails/active_record_association_adapter.rb', line 6 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/mongo_mapper/plugins/rails/active_record_association_adapter.rb', line 6 def @options end |
Class Method Details
.for_association(association) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/mongo_mapper/plugins/rails/active_record_association_adapter.rb', line 8 def self.for_association(association) macro = case association when MongoMapper::Plugins::Associations::BelongsToAssociation :belongs_to when MongoMapper::Plugins::Associations::ManyAssociation :has_many when MongoMapper::Plugins::Associations::OneAssociation :has_one else raise "no #{name} for association of type #{association.class}" end new(association, macro) end |