Class: ActiveData::Model::Associations::Reflections::ReferencesMany
- Inherits:
-
ReferencesAny
- Object
- Base
- ReferencesAny
- ActiveData::Model::Associations::Reflections::ReferencesMany
- Defined in:
- lib/active_data/model/associations/reflections/references_many.rb
Constant Summary
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
#name, #options, #parent_reflection
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from ReferencesAny
#autosave?, #embedded?, #initialize, #inspect, #klass, #persistence_adapter, persistence_adapter, #read_source, #write_source
Methods inherited from Base
association_class, #belongs_to?, #build_association, #collection?, #default, generate_methods, #initialize, #klass, #macro, #read_source, #write_source
Constructor Details
This class inherits a constructor from ActiveData::Model::Associations::Reflections::ReferencesAny
Class Method Details
.build(target, generated_methods, name, *args, &block) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/active_data/model/associations/reflections/references_many.rb', line 9 def self.build(target, generated_methods, name, *args, &block) reflection = super target.add_attribute( ActiveData::Model::Attributes::Reflections::ReferenceMany, reflection.reference_key, association: name ) reflection end |
Instance Method Details
#reference_key ⇒ Object
20 21 22 23 |
# File 'lib/active_data/model/associations/reflections/references_many.rb', line 20 def reference_key @reference_key ||= [:reference_key].presence.try(:to_sym) || :"#{name.to_s.singularize}_#{primary_key.to_s.pluralize}" end |