Class: ActiveFedora::Associations::ContainedFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/active_fedora/associations/contained_finder.rb

Overview

Finds the objects which associate with a given record and are contained within the given container. Uses #repository to find the objects.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(container:, repository:) ⇒ ContainedFinder

Returns a new instance of ContainedFinder.

Parameters:

  • container (#contained_ids)

    a container that records are stored under.

  • repository (#translate_uri_to_id, #find)

    a repository to build objects from.



12
13
14
15
# File 'lib/active_fedora/associations/contained_finder.rb', line 12

def initialize(container:, repository:)
  @container = container
  @repository = repository
end

Instance Attribute Details

#containerObject (readonly)

Returns the value of attribute container.



6
7
8
# File 'lib/active_fedora/associations/contained_finder.rb', line 6

def container
  @container
end

#repositoryObject (readonly)

Returns the value of attribute repository.



6
7
8
# File 'lib/active_fedora/associations/contained_finder.rb', line 6

def repository
  @repository
end

Instance Method Details

#find(record) ⇒ Array<ActiveFedora::Base>

Returns This returns whatever type repository.find returns.

Parameters:

Returns:



21
22
23
24
# File 'lib/active_fedora/associations/contained_finder.rb', line 21

def find(record)
  record.reload
  repository.find(matching_ids(record))
end