Sha256: 98fe49312a40765c42b83502c05fc5f4b709008cba3c33d326b55a4cdf8a58d1

Contents?: true

Size: 901 Bytes

Versions: 50

Compression:

Stored size: 901 Bytes

Contents

module ActiveFedora
  module RDF
    #
    # Mixin for adding datastream persistence to an ActiveTriples::Resource
    # descendant so that it may be used to back an ActiveFedora::RDFDatastream.
    #
    # @see ActiveFedora::RDFDatastream.resource_class
    # @see ActiveFedora::RDF::ObjectResource
    #
    module Persistence
      extend ActiveSupport::Concern

      BASE_URI = 'info:fedora/'.freeze

      included do
        configure base_uri: BASE_URI unless base_uri
        attr_accessor :datastream
      end

      # Overrides ActiveTriples::Resource
      def persist!
        return false unless datastream && datastream.respond_to?(:save)
        @persisted ||= datastream.save
      end

      # Overrides ActiveTriples::Resource
      def persisted?
        return true if frozen? && !datastream.new_record?
        @persisted ||= !datastream.new_record?
      end
    end
  end
end

Version data entries

50 entries across 50 versions & 1 rubygems

Version Path
active-fedora-13.3.0 lib/active_fedora/rdf/persistence.rb
active-fedora-12.2.4 lib/active_fedora/rdf/persistence.rb
active-fedora-13.2.7 lib/active_fedora/rdf/persistence.rb
active-fedora-13.2.5 lib/active_fedora/rdf/persistence.rb
active-fedora-13.2.4 lib/active_fedora/rdf/persistence.rb
active-fedora-12.2.3 lib/active_fedora/rdf/persistence.rb
active-fedora-13.2.3 lib/active_fedora/rdf/persistence.rb
active-fedora-13.2.2 lib/active_fedora/rdf/persistence.rb
active-fedora-13.2.0 lib/active_fedora/rdf/persistence.rb
active-fedora-13.1.3 lib/active_fedora/rdf/persistence.rb
active-fedora-11.5.6 lib/active_fedora/rdf/persistence.rb
active-fedora-12.2.2 lib/active_fedora/rdf/persistence.rb
active-fedora-11.2.1 lib/active_fedora/rdf/persistence.rb
active-fedora-12.2.1 lib/active_fedora/rdf/persistence.rb
active-fedora-12.0.3 lib/active_fedora/rdf/persistence.rb
active-fedora-11.5.5 lib/active_fedora/rdf/persistence.rb
active-fedora-13.1.2 lib/active_fedora/rdf/persistence.rb
active-fedora-13.1.1 lib/active_fedora/rdf/persistence.rb
active-fedora-13.1.0 lib/active_fedora/rdf/persistence.rb
active-fedora-13.0.0 lib/active_fedora/rdf/persistence.rb