Skip to content

Commit

Permalink
Further simplification and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
cjcolvar committed Sep 11, 2023
1 parent 6568210 commit 31aaa3e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 20 deletions.
1 change: 0 additions & 1 deletion app/models/master_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ def media_object=(mo)
self._media_object=(mo)
unless self.media_object.nil?
self.media_object.ordered_master_files += [self]
self.media_object.master_files = self.media_object.ordered_master_files.to_a
self.media_object.save
end
end
Expand Down
40 changes: 21 additions & 19 deletions config/initializers/active_fedora_general.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,30 +152,32 @@ def changes
end

ActiveFedora::Associations::IndirectlyContainsAssociation.class_eval do
def insert_record(record, force = true, validate = true)
container.save!
if force
record.save!
else
return false unless record.save(validate: validate)
end
def insert_record(record, force = true, validate = true)
container.save!
if force
record.save!
else
return false unless record.save(validate: validate)
end

save_through_record(record)
save_through_record(record)

owner.send(:attribute_will_change!, reflection.name)
owner.resource << ::RDF::Statement(owner.resource, reflection.predicate, record.id)
owner.save
# Add triples to the parent object
owner.send(:attribute_will_change!, reflection.name)
owner.resource << ::RDF::Statement(owner.resource, reflection.predicate, record.id)
owner.save

true
end
true
end

private

def delete_record(record)
record_proxy_finder.find(record).delete
def delete_record(record)
record_proxy_finder.find(record).delete

owner.send(:attribute_will_change!, reflection.name)
owner.resource.delete({ predicate: reflection.predicate, object: record.id})
owner.save
end
# Remove triples from the parent object
owner.send(:attribute_will_change!, reflection.name)
owner.resource.delete({ predicate: reflection.predicate, object: record.id})
owner.save
end
end

0 comments on commit 31aaa3e

Please sign in to comment.