module ActiveFedora::Reflection

def add_reflection(active_fedora, name, reflection)

def add_reflection(active_fedora, name, reflection)
  active_fedora.clear_reflections_cache
  # FIXME: this is where the problem with association_spec is caused (key is string now)
  active_fedora._reflections = active_fedora._reflections.merge(name => reflection)
end

def create(macro, name, scope, options, active_fedora)

def create(macro, name, scope, options, active_fedora)
  klass = case macro
          when :has_many
            HasManyReflection
          when :belongs_to
            BelongsToReflection
          when :has_and_belongs_to_many
            HasAndBelongsToManyReflection
          when :has_subresource
            HasSubresourceReflection
          when :directly_contains
            DirectlyContainsReflection
          when :directly_contains_one
            DirectlyContainsOneReflection
          when :indirectly_contains
            IndirectlyContainsReflection
          when :is_a_container
            BasicContainsReflection
          when :rdf
            RDFPropertyReflection
          when :singular_rdf
            SingularRDFPropertyReflection
          when :filter
            FilterReflection
          when :aggregation, :orders
            OrdersReflection
          else
            raise "Unsupported Macro: #{macro}"
          end
  reflection = klass.new(name, scope, options, active_fedora)
  add_reflection(active_fedora, name, reflection)
  reflection
end

def reflections

def reflections
  self.class.reflections
end