Class: Collection

Inherits:
ActiveFedora::Base
  • Object
show all
Includes:
Hydra::AccessControls::Permissions, Hydra::AccessControls::WithAccessRight, Hydra::Collection, Sufia::Noid
Defined in:
app/repository_models/collection.rb

Instance Method Summary collapse

Instance Method Details

#add_member(collectible) ⇒ Object



22
23
24
25
26
# File 'app/repository_models/collection.rb', line 22

def add_member(collectible)
  return false unless collectible
  self.members << collectible
  self.save
end

#add_relationship(predicate, target, literal = false) ⇒ Object


overriding method from active-fedora: lib/active_fedora/semantic_node.rb

The purpose of this override is to ensure that a collection cannot contain itself.

TODO: After active-fedora 7.0 is released, this logic can be moved into a before_add callback.




52
53
54
55
# File 'app/repository_models/collection.rb', line 52

def add_relationship(predicate, target, literal=false)
  return if self == target
  super
end

#human_readable_typeObject

Reads from resource_type attribute. Defaults to “Collection”, but can be set to something else. Profiles are marked with resource_type of “Profile” when they’re created by the associated Person object This is used to populate the Object Type Facet



18
19
20
# File 'app/repository_models/collection.rb', line 18

def human_readable_type
  self.resource_type ||= "Collection"
end

#is_profile?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'app/repository_models/collection.rb', line 28

def is_profile?
  !associated_persons.empty?
end

#to_sObject



32
33
34
# File 'app/repository_models/collection.rb', line 32

def to_s
  self.title.nil? ? self.inspect : self.title
end

#to_solr(solr_doc = {}, opts = {}) ⇒ Object



36
37
38
39
40
# File 'app/repository_models/collection.rb', line 36

def to_solr(solr_doc={}, opts={})
  super
  Solrizer.set_field(solr_doc, 'generic_type', 'Collection', :facetable)
  solr_doc
end