Class: ActiveFedora::Associations::BasicContainsAssociation
- Inherits:
-
ContainsAssociation
- Object
- Association
- CollectionAssociation
- ContainsAssociation
- ActiveFedora::Associations::BasicContainsAssociation
- Defined in:
- lib/active_fedora/associations/basic_contains_association.rb
Overview
:nodoc:
Instance Attribute Summary
Attributes inherited from CollectionAssociation
Attributes inherited from Association
#inversed, #owner, #reflection, #target
Instance Method Summary collapse
- #add_to_target(record, skip_callbacks = false) ⇒ Object
- #find_target ⇒ Object
- #insert_record(record, force = true, validate = true) ⇒ Object
- #reset ⇒ Object
Methods inherited from ContainsAssociation
Methods inherited from CollectionAssociation
#any?, #build, #concat, #concat_records, #count, #create, #create!, #delete, #delete_all, #destroy, #destroy_all, #empty?, #find, #first, #ids_reader, #ids_writer, #include?, #last, #load_from_solr, #load_target, #null_scope?, #reader, #replace, #scope, #select, #size, #target=, #to_ary, #writer
Methods inherited from Association
#association_scope, #initialize, #initialize_attributes, #load_target, #loaded!, #loaded?, #reload, #reset_scope, #scope, #set_inverse_instance, #stale_target?, #target_scope
Constructor Details
This class inherits a constructor from ActiveFedora::Associations::Association
Instance Method Details
#add_to_target(record, skip_callbacks = false) ⇒ Object
16 17 18 19 |
# File 'lib/active_fedora/associations/basic_contains_association.rb', line 16 def add_to_target(record, skip_callbacks = false) record.base_path_for_resource = owner.uri.to_s super end |
#find_target ⇒ Object
4 5 6 7 8 9 |
# File 'lib/active_fedora/associations/basic_contains_association.rb', line 4 def find_target uris = owner.resource.query(predicate: [:predicate]) .map { |r| r.object.to_s } uris.map { |object_uri| klass.find(klass.uri_to_id(object_uri)) } end |
#insert_record(record, force = true, validate = true) ⇒ Object
11 12 13 14 |
# File 'lib/active_fedora/associations/basic_contains_association.rb', line 11 def insert_record(record, force = true, validate = true) record.base_path_for_resource = owner.uri.to_s super end |
#reset ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/active_fedora/associations/basic_contains_association.rb', line 21 def reset # Update the membership triples (and no other triples) on the the owner's resource if owner.persisted? pattern = ::RDF::Query::Pattern.new(predicate: [:predicate]) new_resource = ActiveFedora::Base.uncached do owner.dup.reload.resource end owner.resource.delete_insert([pattern], new_resource.query(pattern)) end super end |