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>
- #member_of_collection_ids ⇒ Enumerable<String>
-
#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_member_ids ⇒ Enumerable<String>
An ordered list of member ids.
-
#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.
138 139 140 |
# File 'lib/hydra/pcdm/models/concerns/pcdm_behavior.rb', line 138 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.
124 125 126 |
# File 'lib/hydra/pcdm/models/concerns/pcdm_behavior.rb', line 124 def in_collection_ids in_collections.map(&:id) end |
#in_collections ⇒ Enumerable<Hydra::PCDM::CollectionBehavior>
Returns the collections the object is a member of.
119 120 121 |
# File 'lib/hydra/pcdm/models/concerns/pcdm_behavior.rb', line 119 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 |
#member_of_collection_ids ⇒ Enumerable<String>
130 131 132 |
# File 'lib/hydra/pcdm/models/concerns/pcdm_behavior.rb', line 130 def member_of_collection_ids member_of_collections.map(&:id) end |
#object_ids ⇒ Enumerable<String>
Gives a subset of #member_ids, where all elements are PCDM objects.
98 99 100 |
# File 'lib/hydra/pcdm/models/concerns/pcdm_behavior.rb', line 98 def object_ids objects.map(&:id) end |
#objects ⇒ Enumerable<PCDM::ObjectBehavior>
Gives the subset of #members that are PCDM objects
91 92 93 |
# File 'lib/hydra/pcdm/models/concerns/pcdm_behavior.rb', line 91 def objects members.select(&:pcdm_object?) end |
#ordered_member_ids ⇒ Enumerable<String>
Returns an ordered list of member ids.
82 83 84 |
# File 'lib/hydra/pcdm/models/concerns/pcdm_behavior.rb', line 82 def ordered_member_ids ordered_member_proxies.map(&:target_id) end |
#ordered_object_ids ⇒ Enumerable<String>
Returns an ordered list of member ids.
112 113 114 |
# File 'lib/hydra/pcdm/models/concerns/pcdm_behavior.rb', line 112 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.
106 107 108 |
# File 'lib/hydra/pcdm/models/concerns/pcdm_behavior.rb', line 106 def ordered_objects ordered_members.to_a.select(&:pcdm_object?) end |