Module: ActiveFedora::Aggregation::BaseExtension::ClassMethods

Defined in:
lib/active_fedora/aggregation/base_extension.rb

Instance Method Summary collapse

Instance Method Details

#aggregates(name, options = {}) ⇒ Object

Create an aggregation association on the class

Examples:

class Image < ActiveFedora::Base
  aggregates :generic_files
end


31
32
33
# File 'lib/active_fedora/aggregation/base_extension.rb', line 31

def aggregates(name, options={})
  Builder.build(self, name, options)
end

#create_reflection(macro, name, options, active_fedora) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/active_fedora/aggregation/base_extension.rb', line 47

def create_reflection(macro, name, options, active_fedora)
  case macro
  when :aggregation
    Reflection.new(macro, name, options, active_fedora).tap do |reflection|
      add_reflection name, reflection
    end
  when :filter
    ActiveFedora::Filter::Reflection.new(macro, name, options, active_fedora).tap do |reflection|
      add_reflection name, reflection
    end
  else
    super
  end
end

#filters_association(extending_from, options = {}) ⇒ Object

Create an association filter on the class

Examples:

class Image < ActiveFedora::Base
  aggregates :generic_files
  filters_association :generic_files, as: :large_files, condition: :big_file?
end


42
43
44
45
# File 'lib/active_fedora/aggregation/base_extension.rb', line 42

def filters_association(extending_from, options={})
  name = options.delete(:as)
  ActiveFedora::Filter::Builder.build(self, name, options.merge(extending_from: extending_from))
end