Class: ActiveFedora::Associations::RDF

Inherits:
SingularAssociation show all
Defined in:
lib/active_fedora/associations/rdf.rb

Overview

:nodoc:

Direct Known Subclasses

SingularRDF

Instance Attribute Summary

Attributes inherited from Association

#inversed, #owner, #reflection, #target

Instance Method Summary collapse

Methods inherited from SingularAssociation

#build, #create, #create!, #writer

Methods inherited from Association

#association_scope, #initialize, #initialize_attributes, #load_target, #loaded!, #loaded?, #reload, #reset, #scope, #set_inverse_instance, #stale_target?, #target_scope

Constructor Details

This class inherits a constructor from ActiveFedora::Associations::Association

Instance Method Details

#destroyObject


19
20
21
22
23
# File 'lib/active_fedora/associations/rdf.rb', line 19

def destroy
  filtered_results.each do |candidate|
    owner.resource.delete([owner.rdf_subject, reflection.predicate, candidate])
  end
end

#readerObject


15
16
17
# File 'lib/active_fedora/associations/rdf.rb', line 15

def reader
  filtered_results.map { |val| ActiveFedora::Base.uri_to_id(val) }
end

#replace(values) ⇒ Object


5
6
7
8
9
10
11
12
13
# File 'lib/active_fedora/associations/rdf.rb', line 5

def replace(values)
  raise "can't modify frozen #{owner.class}" if owner.frozen?
  destroy
  values.each do |value|
    uri = ActiveFedora::Base.id_to_uri(value)
    owner.resource.insert [owner.rdf_subject, reflection.predicate, ::RDF::URI.new(uri)]
  end
  owner.send(:attribute_will_change!, reflection.name)
end