Skip to content

Commit

Permalink
[wings] document native models with examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Johnson committed Sep 18, 2019
1 parent 50d991e commit 67fb9bd
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions lib/wings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,44 @@
# However, these dependencies should be considered temprorary: this code will
# be deprecated for removal in a future release.
#
# @example 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"]
#
# @example 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 = MyBookResource.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 https://wiki.duraspace.org/display/samvera/Hyrax-Valkyrie+Development+Working+Group
# for further context regarding the approach
module Wings; end
Expand Down

0 comments on commit 67fb9bd

Please sign in to comment.