Module: EacRailsUtils::Models::TablelessAssociations::ActiveRecordReflection::ClassMethods
- Defined in:
- lib/eac_rails_utils/models/tableless_associations/active_record_reflection.rb
Instance Method Summary collapse
- #create_reflection(macro, name, scope, options, active_record) ⇒ Object
- #reflect_on_association(association) ⇒ Object
Instance Method Details
#create_reflection(macro, name, scope, options, active_record) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/eac_rails_utils/models/tableless_associations/active_record_reflection.rb', line 17 def create_reflection(macro, name, scope, , active_record) case macro when :has_many, :belongs_to klass = ActiveRecord::Reflection::AssociationReflection reflection = klass.new(macro, name, scope, , active_record) end self.reflections = self.reflections.merge(name => reflection) reflection end |
#reflect_on_association(association) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/eac_rails_utils/models/tableless_associations/active_record_reflection.rb', line 29 def reflect_on_association(association) if ActiveRecord.version >= Gem::Version.new("4.1.2") _reflections[association.to_s] else reflections[association] end end |