Module: ActiveAny::Reflection
- Extended by:
- ActiveSupport::Concern
- Included in:
- Base
- Defined in:
- lib/active_any/reflection.rb,
lib/active_any/reflection/has_many_reflection.rb,
lib/active_any/reflection/belongs_to_reflection.rb,
lib/active_any/reflection/association_reflection.rb
Defined Under Namespace
Modules: ClassMethods
Classes: AssociationReflection, BelongsToReflection, HasManyReflection, UnknownPrimaryKey
Class Method Summary
collapse
Class Method Details
.add_reflection(klass, name, reflection) ⇒ Object
47
48
49
|
# File 'lib/active_any/reflection.rb', line 47
def self.add_reflection(klass, name, reflection)
klass._reflections = klass.reflections.merge(name.to_s => reflection)
end
|
.create(macro, name, scope, options, klass) ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/active_any/reflection.rb', line 33
def self.create(macro, name, scope, options, klass)
reflection_class =
case macro
when :belongs_to
BelongsToReflection
when :has_many
HasManyReflection
else
raise "Unsupported Macro: #{macro}"
end
reflection_class.new(name, scope, options, klass)
end
|