module Neo4j::ActiveNode::Unpersisted
Public Instance Methods
clear_deferred_nodes_for_association(association_name)
click to toggle source
# File lib/neo4j/active_node/unpersisted.rb 24 def clear_deferred_nodes_for_association(association_name) 25 deferred_nodes_for_association(association_name.to_sym).clear 26 end
defer_create(association_name, object, options = {})
click to toggle source
# File lib/neo4j/active_node/unpersisted.rb 10 def defer_create(association_name, object, options = {}) 11 clear_deferred_nodes_for_association(association_name) if options[:clear] 12 13 deferred_nodes_for_association(association_name) << object 14 end
deferred_create_cache()
click to toggle source
The values in this Hash are returned and used outside by reference so any modifications to the Array should be in-place
# File lib/neo4j/active_node/unpersisted.rb 6 def deferred_create_cache 7 @deferred_create_cache ||= {} 8 end
deferred_nodes_for_association(association_name)
click to toggle source
# File lib/neo4j/active_node/unpersisted.rb 16 def deferred_nodes_for_association(association_name) 17 deferred_create_cache[association_name.to_sym] ||= [] 18 end
pending_deferred_creations?()
click to toggle source
# File lib/neo4j/active_node/unpersisted.rb 20 def pending_deferred_creations? 21 !deferred_create_cache.values.all?(&:empty?) 22 end
Private Instance Methods
process_unpersisted_nodes!()
click to toggle source
# File lib/neo4j/active_node/unpersisted.rb 30 def process_unpersisted_nodes! 31 deferred_create_cache.dup.each do |association_name, nodes| 32 association_proxy = association_proxy(association_name) 33 34 nodes.each do |node| 35 if node.respond_to?(:changed?) 36 node.save if node.changed? || !node.persisted? 37 fail "Unable to defer node persistence, could not save #{node.inspect}" unless node.persisted? 38 end 39 40 association_proxy << node 41 end 42 end 43 44 @deferred_create_cache = {} 45 end