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


45
46
47
# File 'lib/active_fedora/aggregation/base_extension.rb', line 45

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

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



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/active_fedora/aggregation/base_extension.rb', line 83

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
  when :orders
    ActiveFedora::Orders::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


78
79
80
81
# File 'lib/active_fedora/aggregation/base_extension.rb', line 78

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

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

Convenience method for building an ordered aggregation.

Examples:

class Image < ActiveFedora::Base
  ordered_aggregation :members, through: :list_source
end


67
68
69
# File 'lib/active_fedora/aggregation/base_extension.rb', line 67

def ordered_aggregation(name, options={})
  ActiveFedora::Orders::AggregationBuilder.build(self, name, options)
end

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

Allows ordering of an association

Examples:

class Image < ActiveFedora::Base
  contains :list_resource, class_name:
    "ActiveFedora::Aggregation::ListSource"
  orders :generic_files, through: :list_resource
end


57
58
59
# File 'lib/active_fedora/aggregation/base_extension.rb', line 57

def orders(name, options={})
  ActiveFedora::Orders::Builder.build(self, name, options)
end