Skip to content

[DEPRECATED; moved into active_fedora] Aggregation relationship for ActiveFedora

License

Notifications You must be signed in to change notification settings

samvera-deprecated/activefedora-aggregation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
May 5, 2015
Mar 25, 2016
Oct 22, 2015
Feb 24, 2016
Mar 25, 2016
Feb 24, 2016
Mar 18, 2015
Mar 18, 2015
Mar 18, 2015
Mar 24, 2016
Mar 18, 2015
Jan 26, 2016
Feb 24, 2016
Mar 25, 2016
Feb 24, 2016

Repository files navigation

Gem Version Build Status

ActiveFedora::Aggregation

Aggregations for ActiveFedora: manage a group of related objects using predicates from the OAI-ORE data model. Provides the foundation for flexible relationships, including items appearing multiple times in a group, flexible/optional ordering, etc.

Used extensively by Hydra::PCDM.

Example

class GenericFile < ActiveFedora::Base
end

generic_file1 = GenericFile.create(id: 'file1')
generic_file2 = GenericFile.create(id: 'file2')
generic_file3 = GenericFile.create(id: 'file3')

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

image = Image.create(id: 'my_image')
image.ordered_generic_file_proxies.append_target generic_file2
image.ordered_generic_file_proxies.append_target generic_file1
image.save
image.generic_files # => [#<GenericFile id: "file2">, #<GenericFile id: "file1">]
image.ordered_generic_files.to_a # => [#<GenericFile id: "file2">, #<GenericFile id: "file1">]

# Not all generic files must be ordered.
image.generic_files += [generic_file3]
image.generic_files => [#<GenericFile id: "file2">, #<GenericFile id: "file1">, #<GenericFile id: "file3">]
image.ordered_generic_files.to_a => [#<GenericFile id: "file2">, #<GenericFile id: "file1">]

# non-ordered accessor is not ordered.
image.ordered_generic_file_proxies.insert_target_at(0, generic_file3)
image.generic_files # => [#<GenericFile id: "file2">, #<GenericFile id: "file1">, #<GenericFile id: "file3">]
image.ordered_generic_files.to_a # => [#<GenericFile id: "file3">, #<GenericFile id: "file2">, #<GenericFile id: "file1">] 

# Deletions
image.ordered_generic_file_proxies.delete_at(1) => #<GenericFile id: "file2">
image.ordered_generic_files.to_a # => [#<GenericFile id: "file3">, #<GenericFile id: "file1">]
image.generic_files # => [#<GenericFile id: "file2">, #<GenericFile id: "file1">, #<GenericFile id: "file3">]

About

[DEPRECATED; moved into active_fedora] Aggregation relationship for ActiveFedora

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published