Module: ActiveFedora::Reflection

Extended by:
ActiveSupport::Concern
Included in:
Base
Defined in:
lib/active_fedora/reflection.rb

Overview

:nodoc:

Defined Under Namespace

Modules: ClassMethods Classes: AbstractReflection, AssociationReflection, BasicContainsReflection, BelongsToReflection, DirectlyContainsOneReflection, DirectlyContainsReflection, FilterReflection, HasAndBelongsToManyReflection, HasManyReflection, HasSubresourceReflection, IndirectlyContainsReflection, MacroReflection, OrdersReflection, RDFPropertyReflection, SingularRDFPropertyReflection

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.add_reflection(active_fedora, name, reflection) ⇒ Object



49
50
51
52
53
# File 'lib/active_fedora/reflection.rb', line 49

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

.create(macro, name, scope, options, active_fedora) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/active_fedora/reflection.rb', line 15

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

Instance Method Details

#reflectionsObject



10
11
12
# File 'lib/active_fedora/reflection.rb', line 10

def reflections
  self.class.reflections
end