Skip to content

Commit

Permalink
Persistence comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mjsuhonos committed Apr 6, 2016
1 parent 4dc5c7e commit 107b4e2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/active_triples/mongoid_strategy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ def destroy
#
# @return [true] returns true if the save did not error
def persist!
# NB: this hits the database a couple of times!
return true if document.destroyed?
update_document unless source.empty?
# update_document unless document.destroyed?
@persisted = true
end

Expand Down Expand Up @@ -76,7 +78,11 @@ def update_document
json = JSON.parse(source.dump(:jsonld, standard_prefixes: true, useNativeTypes: true))

# NB: This will assign attributes AND save the document
# NB: when document is destroyed, attributes are frozen
document.update_attributes JSON::LD::API.flatten(json, json['@context'], rename_bnodes: false)

# TODO: consider alternative serialization
# document.update_attributes source.attributes unless document.destroyed?
end

##
Expand Down

0 comments on commit 107b4e2

Please sign in to comment.