Sha256: 912f3561fd7f88eedea1dfa0b0ce1b3d82f6aa0e9e4f737298b6dee1882be1b8
Contents?: true
Size: 1.21 KB
Versions: 6
Compression:
Stored size: 1.21 KB
Contents
# frozen_string_literal: true require 'valkyrie/persistence/postgres/orm_converter' require 'valkyrie/persistence/postgres/resource_converter' module Valkyrie::Persistence::Postgres # Provides access to generic methods for converting to/from # {Valkyrie::Resource} and {Valkyrie::Persistence::Postgres::ORM::Resource}. class ResourceFactory class << self # @param object [Valkyrie::Persistence::Postgres::ORM::Resource] AR # record to be converted. # @return [Valkyrie::Resource] Model representation of the AR record. def to_resource(object:) ::Valkyrie::Persistence::Postgres::ORMConverter.new(object).convert! end # @param resource [Valkyrie::Resource] Model to be converted to ActiveRecord. # @return [Valkyrie::Persistence::Postgres::ORM::Resource] ActiveRecord # resource for the Valkyrie resource. def from_resource(resource:) ::Valkyrie::Persistence::Postgres::ResourceConverter.new(resource, resource_factory: self).convert! end # Accessor for the ActiveRecord class which all Postgres resources are an # instance of. def orm_class ::Valkyrie::Persistence::Postgres::ORM::Resource end end end end
Version data entries
6 entries across 6 versions & 1 rubygems