Class: GalterIrExporter::Migration::Survey::FedoraIdService

Inherits:
Object
  • Object
show all
Defined in:
lib/galter_ir_exporter/migration/survey/fedora_id_service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeFedoraIdService

initialize the service with the default models (GenericFile & Collection) registered



10
11
12
# File 'lib/galter_ir_exporter/migration/survey/fedora_id_service.rb', line 10

def initialize
  @model_registry = default_registry
end

Instance Attribute Details

#model_registryObject

Returns the value of attribute model_registry.



7
8
9
# File 'lib/galter_ir_exporter/migration/survey/fedora_id_service.rb', line 7

def model_registry
  @model_registry
end

Instance Method Details

#call(limit = :all) ⇒ Object

returns a list of ids for all the registered classes in the repository

Parameters:

  • limit (Number) (defaults to: :all)

    limits the number of results (default is all)



27
28
29
30
31
# File 'lib/galter_ir_exporter/migration/survey/fedora_id_service.rb', line 27

def call(limit = :all)
  ids = all_ids.select { |id| registered_model?(id) }
  return ids if limit == :all
  ids.take(limit)
end

#register_model(model_class) ⇒ Object

register an additional ActiveFedora Model to extract ids for

Parameters:

  • model_class (Class)

    additional class that you would like to be in the output

Raises:

  • (RegistryError)

    if the class is not an ActiveFedora based class



18
19
20
21
22
# File 'lib/galter_ir_exporter/migration/survey/fedora_id_service.rb', line 18

def register_model(model_class)
  raise(RegistryError, "Model (#{model_class.name}) for conversion must be an ActiveFedora::Base") unless model_class.ancestors.include?(ActiveFedora::Base)
  return if @model_registry.include? model_class
  @model_registry << model_class
end