Module: Hydra::PCDM::AncestorChecker

Defined in:
lib/hydra/pcdm/ancestor_checker.rb

Overview

Checks whether or not one object is an ancestor of another.

Class Method Summary collapse

Class Method Details

.former_is_ancestor_of_latter?(potential_ancestor, record) ⇒ Boolean Also known as: call

Returns Boolean.

Parameters:

  • options (Hash)
  • record (Hash)

    a customizable set of options

  • potential_ancestor (Hash)

    a customizable set of options

Options Hash (potential_ancestor):

  • (#pcdm_behavior?)

Options Hash (record):

  • (#pcdm_behavior?)

Returns:

  • (Boolean)

    Boolean



9
10
11
12
13
14
# File 'lib/hydra/pcdm/ancestor_checker.rb', line 9

def self.former_is_ancestor_of_latter?(potential_ancestor, record)
  return true if record == potential_ancestor
  return false unless potential_ancestor.respond_to?(:members)
  return true if Array.wrap(potential_ancestor.members).detect { |member| former_is_ancestor_of_latter?(member, record) }
  false
end