Module: ActiveFedora::RDF::Persistence

Extended by:
ActiveSupport::Concern
Defined in:
lib/active_fedora/rdf/persistence.rb

Overview

Mixin for adding datastream persistence to an ActiveTriples::Resource descendant so that it may be used to back an ActiveFedora::RDFDatastream.

See Also:

  • ActiveFedora::RDFDatastream.resource_class
  • ObjectResource

Constant Summary collapse

BASE_URI =
'info:fedora/'.freeze

Instance Method Summary collapse

Instance Method Details

#persist!Object

Overrides ActiveTriples::Resource



21
22
23
24
# File 'lib/active_fedora/rdf/persistence.rb', line 21

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

#persisted?Boolean

Overrides ActiveTriples::Resource

Returns:

  • (Boolean)


27
28
29
30
# File 'lib/active_fedora/rdf/persistence.rb', line 27

def persisted?
  return true if frozen? && !datastream.new_record?
  @persisted ||= !datastream.new_record?
end