Module: Hyrax::CollectionBehavior
- Extended by:
- ActiveSupport::Concern
- Includes:
- Hydra::AccessControls::WithAccessRight, Hydra::WithDepositor, Hydra::Works::CollectionBehavior, CollectionNesting, CoreMetadata, HasRepresentative, HumanReadableType, Noid, Permissions
- Included in:
- Collection
- Defined in:
- app/models/concerns/hyrax/collection_behavior.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#add_member_objects(new_member_ids) ⇒ Object
Add member objects by adding this collection to the objects’ member_of_collection association.
-
#add_members(new_member_ids) ⇒ Object
Add members using the members association.
-
#bytes ⇒ Fixnum
deprecated
Deprecated.
to be removed in 4.0.0; this feature was replaced with a hard-coded null implementation
-
#collection_type ⇒ Object
Get the collection_type when accessed.
- #collection_type=(new_collection_type) ⇒ Object
-
#member_object_ids ⇒ Object
Use this query to get the ids of the member objects (since the containment association has been flipped).
-
#member_objects ⇒ Enumerable<ActiveFedora::Base>
An enumerable over the children of this collection.
-
#permission_template ⇒ Hyrax::PermissionTemplate
Retrieve the permission template for this collection.
-
#reset_access_controls! ⇒ Object
deprecated
Deprecated.
use PermissionTemplate#reset_access_controls_for instead
- #to_s ⇒ Object
Methods included from CollectionNesting
#find_children_of, #reindex_extent, #reindex_extent=, #update_index, #use_nested_reindexing?
Methods included from Permissions::Readable
#private?, #public?, #registered?
Methods included from Permissions::Writable
Methods included from HumanReadableType
#human_readable_type, #to_solr
Methods included from Noid
Instance Method Details
#add_member_objects(new_member_ids) ⇒ Object
Add member objects by adding this collection to the objects’ member_of_collection association.
65 66 67 68 69 70 71 |
# File 'app/models/concerns/hyrax/collection_behavior.rb', line 65 def add_member_objects(new_member_ids) Deprecation.warn("'##{__method__}' will be removed in Hyrax 4.0. " \ "Instead, use Hyrax::Collections::CollectionMemberService.add_members_by_ids.") Hyrax::Collections::CollectionMemberService.add_members_by_ids(collection_id: id, new_member_ids: new_member_ids, user: nil) end |
#add_members(new_member_ids) ⇒ Object
Add members using the members association.
55 56 57 58 59 60 61 |
# File 'app/models/concerns/hyrax/collection_behavior.rb', line 55 def add_members(new_member_ids) Deprecation.warn("'##{__method__}' will be removed in Hyrax 4.0. " \ "Instead, use Hyrax::Collections::CollectionMemberService.add_members_by_ids.") Hyrax::Collections::CollectionMemberService.add_members_by_ids(collection_id: id, new_member_ids: new_member_ids, user: nil) end |
#bytes ⇒ Fixnum
to be removed in 4.0.0; this feature was replaced with a hard-coded null implementation
Returns 0.
108 109 110 111 112 113 114 |
# File 'app/models/concerns/hyrax/collection_behavior.rb', line 108 def bytes Deprecation.warn('#bytes has been deprecated for removal in Hyrax 4.0.0; ' \ 'The implementation of the indexed Collection size ' \ 'feature is extremely inefficient, so it has been removed. ' \ 'This method now returns a hard-coded `0` for compatibility.') 0 end |
#collection_type ⇒ Object
Get the collection_type when accessed
46 47 48 |
# File 'app/models/concerns/hyrax/collection_behavior.rb', line 46 def collection_type @collection_type ||= Hyrax::CollectionType.find_by_gid!(collection_type_gid) end |
#collection_type=(new_collection_type) ⇒ Object
50 51 52 |
# File 'app/models/concerns/hyrax/collection_behavior.rb', line 50 def collection_type=(new_collection_type) self.collection_type_gid = new_collection_type.to_global_id end |
#member_object_ids ⇒ Object
Use this query to get the ids of the member objects (since the containment association has been flipped)
80 81 82 83 |
# File 'app/models/concerns/hyrax/collection_behavior.rb', line 80 def member_object_ids return [] unless id member_objects.map(&:id) end |
#member_objects ⇒ Enumerable<ActiveFedora::Base>
Returns an enumerable over the children of this collection.
74 75 76 |
# File 'app/models/concerns/hyrax/collection_behavior.rb', line 74 def member_objects ActiveFedora::Base.where("member_of_collection_ids_ssim:#{id}") end |
#permission_template ⇒ Hyrax::PermissionTemplate
Retrieve the permission template for this collection.
120 121 122 |
# File 'app/models/concerns/hyrax/collection_behavior.rb', line 120 def Hyrax::PermissionTemplate.find_by!(source_id: id) end |
#reset_access_controls! ⇒ Object
use PermissionTemplate#reset_access_controls_for instead
Calculate and update who should have read/edit access to the collections based on who has access in PermissionTemplateAccess
129 130 131 132 133 134 |
# File 'app/models/concerns/hyrax/collection_behavior.rb', line 129 def reset_access_controls! Deprecation.warn("reset_access_controls! is deprecated; use PermissionTemplate#reset_access_controls_for instead.") .reset_access_controls_for(collection: self, interpret_visibility: true) end |
#to_s ⇒ Object
85 86 87 |
# File 'app/models/concerns/hyrax/collection_behavior.rb', line 85 def to_s title.present? ? title.join(' | ') : 'No Title' end |