Module: Wings

Defined in:
lib/wings.rb,
lib/wings/valkyrizable.rb,
lib/wings/orm_converter.rb,
lib/wings/model_registry.rb,
lib/wings/valkyrie/storage.rb,
lib/wings/model_transformer.rb,
lib/wings/valkyrie/persister.rb,
lib/wings/attribute_transformer.rb,
lib/wings/converter_value_mapper.rb,
lib/wings/valkyrie/query_service.rb,
lib/wings/active_fedora_converter.rb,
lib/wings/active_fedora_classifier.rb,
lib/wings/transformer_value_mapper.rb,
lib/wings/valkyrie/metadata_adapter.rb,
lib/wings/valkyrie/resource_factory.rb,
lib/wings/active_fedora_converter/default_work.rb,
lib/wings/active_fedora_converter/nested_resource.rb,
lib/wings/active_fedora_converter/instance_builder.rb,
lib/wings/services/custom_queries/find_ids_by_model.rb,
lib/wings/active_fedora_converter/file_metadata_node.rb,
lib/wings/services/custom_queries/find_file_metadata.rb,
lib/wings/services/custom_queries/find_access_control.rb,
lib/wings/services/custom_queries/find_collections_by_type.rb,
lib/wings/services/custom_queries/find_many_by_alternate_ids.rb

Overview

Wings is a toolkit integrating Valkyrie into Hyrax as a bridge away from the hard dependency on ActiveFedora.

Requiring this module with ‘require ’wings’‘ injects a variety of behavior supporting a gradual transition from existing `ActiveFedora` models and persistence middleware to Valkyrie.

‘Wings` is primarily an isolating namespace for code intended to be removed after a full transition to `Valkyrie` as the persistence middleware for Hyrax. Applications may find it useful to depend directly on this code to facilitate a smooth code migration, much in the way it is being used in this engine. However, these dependencies should be considered temprorary: this code will be deprecated for removal in a future release.

Examples:

casting an ActiveFedora model to Valkyrie

work     = GenericWork.create(title: ['Comet in Moominland'])
resource = work.valkyrie_resource

resource.title # => ["Comet in Moominland"]
resource.title = ["Mumintrollet på kometjakt"]

Hyrax.persister.save(resource: resource)

work.reload
work.title # => ["Mumintrollet på kometjakt"]

defining a native Valkyrie model for use with Wings

# given an `ActiveFodora` model like
class Book < ActiveFedora::Base
  property :author, predicate: ::RDF::URI('http://example.com/ns/author')
  property :title,  predicate: ::RDF::URI('http://example.com/ns/title')
end

# define a `Valkyrie` model with matching attributes,
class BookResource < Hyrax::Resource
  attribute :author, Valkyrie::Types::String
  attribute :title,  Valkyrie::Types::String
end

# and register the relationship with `Wings`
Wings::ModelRegistry.register(BookResource, Book)

# `Wings` will cast the `BookResource` to a `Book` to persist via `ActiveFedora`
resource = BookResource.new(author: 'Tove Jansson', title: 'Comet in Moominland')
adapter  = Wings::Valkyrie::MetadataAdapter.new
resource = adapter.persister.save(resource: resource)

resource.title  # => ["Comet in Moominland"]
resource.author # => ["Tove Jansson"]

resource.is_a?(BookResource) # => true

See Also:

Defined Under Namespace

Modules: CustomQueries, Valkyrie, Valkyrizable, Works Classes: ActiveFedoraAttributes, ActiveFedoraClassifier, ActiveFedoraConverter, ArrayValue, AttributeTransformer, ConverterValueMapper, EnumerableMapper, FedoraProtectedAttributes, FileAttributeTransformer, FileIds, FileMetadataNode, IdValueMapper, MemberIds, MemberOfCollectionIds, ModelRegistry, ModelTransformer, NestedEmbargoValue, NestedLeaseValue, NestedResourceArrayValue, NestedResourceMapper, NestedResourceValue, NilAttributeValue, OrmConverter, PermissionValue, ReflectionIdValue, ReflectionIdsValue, ReservedAttributeValue, ResourceMapper, StorageError, TransformerValueMapper

Class Method Summary collapse

Class Method Details

.WorkSearchBuilder(work_type) ⇒ Object

Provides a search builder for new valkyrie types that are indexed as their corresponding legacy ActiveFedora classes.

Examples:

builder = Wings::WorkSearchBuilder(Monograph)


67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/wings.rb', line 67

def self.WorkSearchBuilder(work_type) # rubocop:disable Naming/MethodName
  Class.new(Hyrax::WorkSearchBuilder) do
    class_attribute :legacy_work_type, instance_writer: false
    self.legacy_work_type = Wings::ModelRegistry.lookup(work_type)

    def work_types
      [legacy_work_type]
    end

    def self.inspect
      "Wings::WorkSearchBuilder(#{legacy_work_type})"
    end
  end
end