Class: GalterIrExporter::Migration::Survey::FedoraIdService
- Inherits:
-
Object
- Object
- GalterIrExporter::Migration::Survey::FedoraIdService
- Defined in:
- lib/galter_ir_exporter/migration/survey/fedora_id_service.rb
Instance Attribute Summary collapse
-
#model_registry ⇒ Object
Returns the value of attribute model_registry.
Instance Method Summary collapse
-
#call(limit = :all) ⇒ Object
returns a list of ids for all the registered classes in the repository.
-
#initialize ⇒ FedoraIdService
constructor
initialize the service with the default models (GenericFile & Collection) registered.
-
#register_model(model_class) ⇒ Object
register an additional ActiveFedora Model to extract ids for.
Constructor Details
#initialize ⇒ FedoraIdService
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_registry ⇒ Object
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
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
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 |