Module: Hyrax::ValkyrieLazyMigration
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/concerns/hyrax/valkyrie_lazy_migration.rb
Overview
This mixin is for Valkyrie::Resource objects to be able to read/write the same Solr document as their corresponding ActiveFedora::Base object.
Defined Under Namespace
Classes: ResourceName
Class Method Summary collapse
-
.migrating(klass, from:, name_class: Hyrax::ValkyrieLazyMigration::ResourceName) ⇒ Object
This function helps configuration a work for a valkyrie migration; namely by helping re-use an existing SOLR document, by specifying that the given :klass is a migration :from another class.
Instance Method Summary collapse
Class Method Details
.migrating(klass, from:, name_class: Hyrax::ValkyrieLazyMigration::ResourceName) ⇒ Object
Note:
This is similar to the Wings::ModelRegistry.register, but is envisioned as part of
This function helps configuration a work for a valkyrie migration; namely by helping re-use an existing SOLR document, by specifying that the given :klass is a migration :from another class.
the Frigg and Freyja adapters for Postges and Fedora lazy migrations.
52 53 54 55 56 57 58 59 60 61 62 |
# File 'app/models/concerns/hyrax/valkyrie_lazy_migration.rb', line 52 def self.(klass, from:, name_class: Hyrax::ValkyrieLazyMigration::ResourceName) Wings::ModelRegistry.register(klass, from) from.singleton_class.define_method(:migrating_from) { from } from.singleton_class.define_method(:migrating_to) { klass } klass.singleton_class.define_method(:migrating_from) { from } klass.singleton_class.define_method(:migrating_to) { klass } klass.singleton_class.define_method(:_hyrax_default_name_class) { name_class } klass.singleton_class.define_method(:to_rdf_representation) { .to_rdf_representation } klass.include(self) end |
Instance Method Details
#members ⇒ Object
70 71 72 73 74 75 76 77 |
# File 'app/models/concerns/hyrax/valkyrie_lazy_migration.rb', line 70 def members return @members if @members.present? @members = member_ids.map do |id| Hyrax.query_service.find_by(id: id) rescue Valkyrie::Persistence::ObjectNotFoundError Rails.logger.warn("Could not find member #{id} for #{self.id}") end end |
#to_solr ⇒ Object
79 80 81 |
# File 'app/models/concerns/hyrax/valkyrie_lazy_migration.rb', line 79 def to_solr Hyrax::ValkyrieIndexer.for(resource: self).to_solr end |