Module: EacRailsUtils::Models::TablelessAssociations::ActiveRecordReflection::ClassMethods

Defined in:
lib/eac_rails_utils/models/tableless_associations/active_record_reflection.rb

Instance Method Summary collapse

Instance Method Details

#create_reflection(macro, name, scope, options, active_record) ⇒ Object



21
22
23
24
25
26
27
28
29
30
# File 'lib/eac_rails_utils/models/tableless_associations/active_record_reflection.rb', line 21

def create_reflection(macro, name, scope, options, active_record)
  case macro
  when :has_many, :belongs_to
    klass = ActiveRecord::Reflection::AssociationReflection
    reflection = klass.new(macro, name, scope, options, active_record)
  end

  self.reflections = reflections.merge(name => reflection)
  reflection
end

#reflect_on_association(association) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/eac_rails_utils/models/tableless_associations/active_record_reflection.rb', line 33

def reflect_on_association(association)
  if ActiveRecord.version >= Gem::Version.new('4.1.2')
    _reflections[association.to_s]
  else
    reflections[association]
  end
end