module Hydra::Works::FileSetBehavior

This module provides all of the Behaviors of a Hydra::Works::GenericFile

behavior:

1) Hydra::Works::FileSet can contain (pcdm:hasFile) Hydra::PCDM::File   (inherits from Hydra::PCDM::Object)
2) Hydra::Works::FileSet can contain (pcdm:hasRelatedFile) Hydra::PCDM::File   (inherits from Hydra::PCDM::Object)
3) Hydra::Works::FileSet can aggregate (pcdm:hasMember) Hydra::Works::FileSet
4) Hydra::Works::FileSet can NOT aggregate anything other than Hydra::Works::FileSets
5) Hydra::Works::FileSet can have descriptive metadata
6) Hydra::Works::FileSet can have access metadata

Public Class Methods

type_validator() click to toggle source
Calls superclass method
# File lib/hydra/works/models/concerns/file_set_behavior.rb, line 15
def self.type_validator
  Hydra::PCDM::Validators::CompositeValidator.new(
    Hydra::Works::NotCollectionValidator,
    super
  )
end

Public Instance Methods

collection?() click to toggle source

@return [Boolean] whether this instance is a Hydra::Works Collection.

# File lib/hydra/works/models/concerns/file_set_behavior.rb, line 32
def collection?
  false
end
file_set?() click to toggle source

@return [Boolean] whether this instance is a Hydra::Works::FileSet.

# File lib/hydra/works/models/concerns/file_set_behavior.rb, line 42
def file_set?
  true
end
in_work_ids() click to toggle source
# File lib/hydra/works/models/concerns/file_set_behavior.rb, line 58
def in_work_ids
  in_works.map(&:id)
end
in_works() click to toggle source
# File lib/hydra/works/models/concerns/file_set_behavior.rb, line 54
def in_works
  ordered_by.select { |parent| parent.class.included_modules.include?(Hydra::Works::WorkBehavior) }.to_a
end
member_of_work_ids() click to toggle source
# File lib/hydra/works/models/concerns/file_set_behavior.rb, line 66
def member_of_work_ids
  member_of_works.map(&:id)
end
member_of_works() click to toggle source
# File lib/hydra/works/models/concerns/file_set_behavior.rb, line 62
def member_of_works
  member_of.select(&:work?).to_a
end
parent_work_ids() click to toggle source
# File lib/hydra/works/models/concerns/file_set_behavior.rb, line 50
def parent_work_ids
  in_work_ids + member_of_work_ids
end
parent_works() click to toggle source
# File lib/hydra/works/models/concerns/file_set_behavior.rb, line 46
def parent_works
  in_works + member_of_works
end
work?() click to toggle source

@return [Boolean] whether this instance is a Hydra::Works Generic Work.

# File lib/hydra/works/models/concerns/file_set_behavior.rb, line 37
def work?
  false
end

Private Instance Methods

remove_from_works() click to toggle source
# File lib/hydra/works/models/concerns/file_set_behavior.rb, line 72
def remove_from_works
  in_works.each do |parent|
    parent.ordered_members.delete(self) # Delete the list node
    parent.members.delete(self) # Delete the indirect container Proxy
    parent.save! # record the changes to the ordered members
  end
end