Class: ActiveData::Model::Associations::Reflections::ReferencesMany
- Inherits:
-
ReferenceReflection
- Object
- Base
- ReferenceReflection
- 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 ReferenceReflection
#embedded?, #initialize, #primary_key, #read_source, #scope, #write_source
Methods inherited from Base
association_class, #belongs_to?, #build_association, #default, generate_methods, #initialize, #inspect, #klass, #macro, #read_source, #write_source
Constructor Details
This class inherits a constructor from ActiveData::Model::Associations::Reflections::ReferenceReflection
Class Method Details
.build(target, generated_methods, name, *args, &block) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/active_data/model/associations/reflections/references_many.rb', line 6 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
#collection? ⇒ Boolean
16 17 18 |
# File 'lib/active_data/model/associations/reflections/references_many.rb', line 16 def collection? true end |
#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 |