Sha256: cc3b39a1c701967ae8189867711a27bee36157faa5e52aeb86482c404a040a18
Contents?: true
Size: 748 Bytes
Versions: 6
Compression:
Stored size: 748 Bytes
Contents
# frozen_string_literal: true module Valkyrie::Persistence::Postgres # Responsible for converting a {Valkyrie::Resource} into a # {Valkyrie::Persistence::Postgres::ORM::Resource} class ResourceConverter delegate :orm_class, to: :resource_factory attr_reader :resource, :resource_factory def initialize(resource, resource_factory:) @resource = resource @resource_factory = resource_factory end def convert! orm_class.find_or_initialize_by(id: resource.id && resource.id.to_s).tap do |orm_object| orm_object.internal_resource = resource.internal_resource orm_object.metadata.merge!(resource.attributes.except(:id, :internal_resource, :created_at, :updated_at)) end end end end
Version data entries
6 entries across 6 versions & 1 rubygems