module NinjaModel::Reflection::ClassMethods

Public Instance Methods

create_reflection(macro, name, options, ninja_model) click to toggle source
# File lib/ninja_model/reflection.rb, line 11
def create_reflection(macro, name, options, ninja_model)
  case macro
  when :has_many, :belongs_to, :has_one
    reflection = Reflection::AssociationReflection.new(macro, name, options, ninja_model)
  when :composed_of
    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)
  reflection
end
reflect_on_aggregation(aggregation) click to toggle source
# File lib/ninja_model/reflection.rb, line 29
def reflect_on_aggregation(aggregation)
  reflections[aggregation].is_a?(AggregateReflection) ? reflections[aggregation] : nil
end
reflect_on_association(association) click to toggle source
# File lib/ninja_model/reflection.rb, line 33
def reflect_on_association(association)
  reflections[association].is_a?(Reflection::AssociationReflection) ? reflections[association] : nil
end
reflections() click to toggle source
# File lib/ninja_model/reflection.rb, line 25
def reflections
  read_inheritable_attribute(:reflections) || write_inheritable_attribute(:reflections, {})
end