Module: CurationConcern::CollectionModel
- Extended by:
- ActiveSupport::Concern
- Includes:
- HasRepresentative, HumanReadableType, Hydra::AccessControls::Permissions, Hydra::AccessControls::WithAccessRight, Hydra::Collection, Hydra::Collections::Collectible, Sufia::Noid
- Defined in:
- app/models/concerns/curation_concern/collection_model.rb
Instance Method Summary collapse
- #add_member(collectible) ⇒ Object
-
#add_relationship(predicate, target, literal = false) ⇒ Object
———————————————— overriding method from active-fedora: lib/active_fedora/semantic_node.rb.
- #can_be_member_of_collection?(collection) ⇒ Boolean
- #to_s ⇒ Object
- #to_solr(solr_doc = {}, opts = {}) ⇒ Object
Methods included from HumanReadableType
Instance Method Details
#add_member(collectible) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'app/models/concerns/curation_concern/collection_model.rb', line 13 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.
49 50 51 52 |
# File 'app/models/concerns/curation_concern/collection_model.rb', line 49 def add_relationship(predicate, target, literal=false) return if self == target super end |
#can_be_member_of_collection?(collection) ⇒ Boolean
34 35 36 |
# File 'app/models/concerns/curation_concern/collection_model.rb', line 34 def can_be_member_of_collection?(collection) collection == self ? false : true end |
#to_s ⇒ Object
22 23 24 |
# File 'app/models/concerns/curation_concern/collection_model.rb', line 22 def to_s self.title.present? ? title : "No Title" end |
#to_solr(solr_doc = {}, opts = {}) ⇒ Object
26 27 28 29 30 31 32 |
# File 'app/models/concerns/curation_concern/collection_model.rb', line 26 def to_solr(solr_doc={}, opts={}) super.tap do |solr_doc| Solrizer.set_field(solr_doc, 'generic_type', human_readable_type, :facetable) solr_doc[Solrizer.solr_name('noid', Sufia::GenericFile.noid_indexer)] = noid index_collection_pids(solr_doc) end end |