module NinjaModel::ActiveRecordExtensions::ReflectionExt::ClassMethods
Public Instance Methods
create_reflection(macro, name, options, ninja_model)
click to toggle source
Calls superclass method
# File lib/ninja_model/rails_ext/active_record.rb, line 52 def create_reflection(macro, name, options, ninja_model) klass = options[:class_name] || name klass = klass.to_s.camelize klass = klass.singularize if macro.in?([:has_many]) klass = compute_type(klass) if NinjaModel.ninja_model?(klass) super else case macro when :has_many, :belongs_to, :has_one reflection = ActiveRecord::Reflection::AssociationReflection.new(macro, name, options, ninja_model) when :composed_of reflection = ActiveRecord::Reflection::AggregateReflection.new(macro, name, options, ninja_model) else raise NotImplementedError, "NinjaModel does not currently support #{macro} associations." end self.reflections = self.reflections.merge(name => reflection) end end
reflect_on_aggregation(aggregation)
click to toggle source
Calls superclass method
# File lib/ninja_model/rails_ext/active_record.rb, line 72 def reflect_on_aggregation(aggregation) if reflections[aggregation].is_a?(ActiveRecord::Reflection::AggregateReflection) reflections[aggregation] else super end end
reflect_on_association(association)
click to toggle source
Calls superclass method
# File lib/ninja_model/rails_ext/active_record.rb, line 80 def reflect_on_association(association) if reflections[association].is_a?(ActiveRecord::Reflection::AssociationReflection) reflections[association] else super end end