Class: ActiveFedora::Associations::IDComposite

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/active_fedora/associations/id_composite.rb

Overview

A composite object for an array of IDs. This abstracts away the fact that an ID might be either a relative ID or a URI to a resource.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ids, id_translator) ⇒ IDComposite

Returns a new instance of IDComposite.

Parameters:

  • ids (Array<#to_s>)

    An array of ids or URIs to convert to IDs.

  • id_translator (#call)

    An object to handle the conversion of a URI to an ID.



11
12
13
14
# File 'lib/active_fedora/associations/id_composite.rb', line 11

def initialize(ids, id_translator)
  @ids = ids
  @id_translator = id_translator
end

Instance Attribute Details

#id_translatorObject (readonly)

Returns the value of attribute id_translator.



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

def id_translator
  @id_translator
end

#idsObject (readonly)

Returns the value of attribute ids.



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

def ids
  @ids
end

Instance Method Details

#eachArray<relative_id>

Returns:

  • (Array<relative_id>)


17
18
19
20
21
# File 'lib/active_fedora/associations/id_composite.rb', line 17

def each
  ids.each do |id|
    yield convert(id)
  end
end