Module: DuckRecord::Reflection
- Extended by:
- ActiveSupport::Concern
- Included in:
- Base
- Defined in:
- lib/duck_record/reflection.rb
Overview
Defined Under Namespace
Modules: ClassMethods
Classes: AbstractReflection, AssociationReflection, HasManyReflection, HasOneReflection, MacroReflection
Class Method Summary
collapse
Class Method Details
.add_reflection(ar, name, reflection) ⇒ Object
29
30
31
32
|
# File 'lib/duck_record/reflection.rb', line 29
def self.add_reflection(ar, name, reflection)
ar.clear_reflections_cache
ar._reflections = ar._reflections.merge(name.to_s => reflection)
end
|
.create(macro, name, options, ar) ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/duck_record/reflection.rb', line 15
def self.create(macro, name, options, ar)
klass = \
case macro
when :has_many
HasManyReflection
when :has_one
HasOneReflection
else
raise "Unsupported Macro: #{macro}"
end
klass.new(name, options, ar)
end
|