Module: CurationConcern::CollectionModel

Extended by:
ActiveSupport::Concern
Includes:
HumanReadableType, Hydra::AccessControls::Permissions, Hydra::AccessControls::WithAccessRight, Sufia::Noid
Included in:
Collection, Profile, ProfileSection
Defined in:
app/repository_models/curation_concern/collection_model.rb

Instance Method Summary collapse

Methods included from HumanReadableType

#human_readable_type

Instance Method Details

#add_member(collectible) ⇒ Object



10
11
12
13
14
15
16
17
# File 'app/repository_models/curation_concern/collection_model.rb', line 10

def add_member(collectible)
  if can_add_to_members?(collectible)
    collectible.collections << self
    collectible.save
    self.members << collectible
    self.save
  end
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.




47
48
49
50
# File 'app/repository_models/curation_concern/collection_model.rb', line 47

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

#remove_member(collectible) ⇒ Object



19
20
21
22
23
24
25
# File 'app/repository_models/curation_concern/collection_model.rb', line 19

def remove_member(collectible)
  return false unless self.members.include?(collectible)
  collectible.collections.delete(self)
  collectible.save
  self.members.delete(collectible)
  self.save
end

#to_sObject



27
28
29
# File 'app/repository_models/curation_concern/collection_model.rb', line 27

def to_s
  self.title.present? ? title : "No Title"
end

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



31
32
33
34
35
# File 'app/repository_models/curation_concern/collection_model.rb', line 31

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