Module: ActiveEntity::Reflection

Extended by:
ActiveSupport::Concern
Included in:
Base
Defined in:
lib/active_entity/reflection.rb

Overview

Active Entity Reflection

Defined Under Namespace

Modules: ClassMethods Classes: AbstractEmbeddedReflection, AbstractReflection, AggregateReflection, EmbeddedAssociationReflection, EmbeddedInReflection, EmbedsManyReflection, EmbedsOneReflection, MacroEmbeddedReflection

Class Method Summary collapse

Class Method Details

.add_aggregate_reflection(ae, name, reflection) ⇒ Object



31
32
33
# File 'lib/active_entity/reflection.rb', line 31

def add_aggregate_reflection(ae, name, reflection)
  ae.aggregate_reflections = ae.aggregate_reflections.merge(name.to_s => reflection)
end

.add_reflection(ar_or_ae, name, reflection) ⇒ Object



25
26
27
28
29
# File 'lib/active_entity/reflection.rb', line 25

def add_reflection(ar_or_ae, name, reflection)
  ar_or_ae.clear_reflections_cache
  name = name.to_s
  ar_or_ae._reflections = ar_or_ae._reflections.except(name).merge!(name => reflection)
end

.create(macro, name, scope, options, ar_or_ae) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/active_entity/reflection.rb', line 17

def create(macro, name, scope, options, ar_or_ae)
  reflection_class_for(macro).new(name, scope, options, ar_or_ae)

  # TODO: Support bridge to Active Entity
  # reflection = reflection_class_for(macro).new(name, scope, options, ar_or_ae)
  # options[:through] ? ActiveRecord::ThroughReflection.new(reflection) : reflection
end