module ActiveRecord::NinjaModelExtensions::ReflectionExt::ClassMethods

Public Instance Methods

create_reflection(macro, name, options, active_record) click to toggle source
Calls superclass method
# File lib/ninja_model/rails_ext/active_record.rb, line 7
def create_reflection(macro, name, options, active_record)
  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)
    case macro
    when :has_many, :belongs_to, :has_one
      reflection = NinjaModel::Reflection::AssociationReflection.new(macro, name, options, active_record)
    else
      raise NotImplementedError, "NinjaModel does not currently support #{macro} associations."
    end
    self.reflections = self.reflections.merge(name => reflection)
    reflection
  else
    super
  end
end
reflect_on_aggregation(aggregation) click to toggle source
Calls superclass method
# File lib/ninja_model/rails_ext/active_record.rb, line 26
def reflect_on_aggregation(aggregation)
  if reflections[aggregation].is_a?(NinjaModel::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 34
def reflect_on_association(association)
  if reflections[association].is_a?(NinjaModel::Reflection::AssociationReflection)
    reflections[association]
  else
    super
  end
end