module Hydra::PCDM::PcdmBehavior

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.

@example Defining a minimal PCDM-like thing

class MyAbomination < ActiveFedora::Base
  def type_validator
    Hydra::PCDM::Validators::PCDMValidator
  end

  include Hydra::PCDM::PcdmBehavior
end

abom = MyAbomination.create

@see ActiveFedora::Base @see Hydra::PCDM::Validators

Public Instance Methods

ancestor?(potential_ancestor) click to toggle source

@param [ActiveFedora::Base] potential_ancestor the resource to check for

ancestorship

@return [Boolean] whether the argument is an ancestor of the object

# 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() click to toggle source

@return [Enumerable<String>] ids for collections the object is a member of

# File lib/hydra/pcdm/models/concerns/pcdm_behavior.rb, line 118
def in_collection_ids
  in_collections.map(&:id)
end
in_collections() click to toggle source

@return [Enumerable<Hydra::PCDM::CollectionBehavior>] the collections the

object is a member of.
# File lib/hydra/pcdm/models/concerns/pcdm_behavior.rb, line 113
def in_collections
  member_of.select(&:pcdm_collection?).to_a
end
member_of() click to toggle source

@return [Enumerable<ActiveFedora::Base>]

# 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() click to toggle source

Gives a subset of member_ids, where all elements are PCDM objects. @return [Enumerable<String>] the object ids

# File lib/hydra/pcdm/models/concerns/pcdm_behavior.rb, line 92
def object_ids
  objects.map(&:id)
end
objects() click to toggle source

Gives the subset of members that are PCDM objects

@return [Enumerable<PCDM::ObjectBehavior>] an enumerable over the members

that are PCDM objects
# File lib/hydra/pcdm/models/concerns/pcdm_behavior.rb, line 85
def objects
  members.select(&:pcdm_object?)
end
ordered_object_ids() click to toggle source

@return [Enumerable<String>] an ordered list of member ids

# File lib/hydra/pcdm/models/concerns/pcdm_behavior.rb, line 106
def ordered_object_ids
  ordered_objects.map(&:id)
end
ordered_objects() click to toggle source

Gives a subset of {#ordered_members}, where all elements are PCDM objects.

@return [Enumerable<PCDM::ObjectBehavior>]

# File lib/hydra/pcdm/models/concerns/pcdm_behavior.rb, line 100
def ordered_objects
  ordered_members.to_a.select(&:pcdm_object?)
end