Module: Hydra::PCDM::PcdmBehavior
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/hydra/pcdm/models/concerns/pcdm_behavior.rb
Overview
Implements behavior for PCDM objects. This behavior is intended for use with another concern completing the set of defined behavior for a PCDM class (e.g. ‘PCDM::ObjectBehavior` or `PCDM::CollectionBehavior`).
A class mixing in this behavior needs to implement type_validator, returning a validator class.
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#ancestor?(potential_ancestor) ⇒ Boolean
Whether the argument is an ancestor of the object.
-
#in_collection_ids ⇒ Enumerable<String>
Ids for collections the object is a member of.
-
#in_collections ⇒ Enumerable<Hydra::PCDM::CollectionBehavior>
The collections the object is a member of.
- #member_of ⇒ Enumerable<ActiveFedora::Base>
-
#object_ids ⇒ Enumerable<String>
Gives a subset of #member_ids, where all elements are PCDM objects.
-
#objects ⇒ Enumerable<PCDM::ObjectBehavior>
Gives the subset of #members that are PCDM objects.
-
#ordered_object_ids ⇒ Enumerable<String>
An ordered list of member ids.
-
#ordered_objects ⇒ Enumerable<PCDM::ObjectBehavior>
Gives a subset of #ordered_members, where all elements are PCDM objects.
Instance Method Details
#ancestor?(potential_ancestor) ⇒ Boolean
Returns whether the argument is an ancestor of the object.
126 127 128 |
# File 'lib/hydra/pcdm/models/concerns/pcdm_behavior.rb', line 126 def ancestor?(potential_ancestor) ::Hydra::PCDM::AncestorChecker.former_is_ancestor_of_latter?(potential_ancestor, self) end |
#in_collection_ids ⇒ Enumerable<String>
Returns ids for collections the object is a member of.
118 119 120 |
# File 'lib/hydra/pcdm/models/concerns/pcdm_behavior.rb', line 118 def in_collection_ids in_collections.map(&:id) end |
#in_collections ⇒ Enumerable<Hydra::PCDM::CollectionBehavior>
Returns the collections the object is a member of.
113 114 115 |
# File 'lib/hydra/pcdm/models/concerns/pcdm_behavior.rb', line 113 def in_collections member_of.select(&:pcdm_collection?).to_a end |
#member_of ⇒ Enumerable<ActiveFedora::Base>
75 76 77 78 |
# File 'lib/hydra/pcdm/models/concerns/pcdm_behavior.rb', line 75 def member_of return [] if id.nil? ActiveFedora::Base.where(Config.indexing_member_ids_key => id) end |
#object_ids ⇒ Enumerable<String>
Gives a subset of #member_ids, where all elements are PCDM objects.
92 93 94 |
# File 'lib/hydra/pcdm/models/concerns/pcdm_behavior.rb', line 92 def object_ids objects.map(&:id) end |
#objects ⇒ Enumerable<PCDM::ObjectBehavior>
Gives the subset of #members that are PCDM objects
85 86 87 |
# File 'lib/hydra/pcdm/models/concerns/pcdm_behavior.rb', line 85 def objects members.select(&:pcdm_object?) end |
#ordered_object_ids ⇒ Enumerable<String>
Returns an ordered list of member ids.
106 107 108 |
# File 'lib/hydra/pcdm/models/concerns/pcdm_behavior.rb', line 106 def ordered_object_ids ordered_objects.map(&:id) end |
#ordered_objects ⇒ Enumerable<PCDM::ObjectBehavior>
Gives a subset of #ordered_members, where all elements are PCDM objects.
100 101 102 |
# File 'lib/hydra/pcdm/models/concerns/pcdm_behavior.rb', line 100 def ordered_objects ordered_members.to_a.select(&:pcdm_object?) end |