Module: ActiveGraph::Node::Unpersisted
- Included in:
- ActiveGraph::Node
- Defined in:
- lib/active_graph/node/unpersisted.rb
Instance Method Summary collapse
- #clear_deferred_nodes_for_association(association_name) ⇒ Object
- #defer_create(association_name, object, options = {}) ⇒ Object
-
#deferred_create_cache ⇒ Object
The values in this Hash are returned and used outside by reference so any modifications to the Array should be in-place.
- #deferred_nodes_for_association(association_name) ⇒ Object
- #pending_deferred_creations? ⇒ Boolean
Instance Method Details
#clear_deferred_nodes_for_association(association_name) ⇒ Object
24 25 26 |
# File 'lib/active_graph/node/unpersisted.rb', line 24 def clear_deferred_nodes_for_association(association_name) deferred_nodes_for_association(association_name.to_sym).clear end |
#defer_create(association_name, object, options = {}) ⇒ Object
10 11 12 13 14 |
# File 'lib/active_graph/node/unpersisted.rb', line 10 def defer_create(association_name, object, = {}) clear_deferred_nodes_for_association(association_name) if [:clear] deferred_nodes_for_association(association_name).concat(Array(object)) end |
#deferred_create_cache ⇒ Object
The values in this Hash are returned and used outside by reference so any modifications to the Array should be in-place
6 7 8 |
# File 'lib/active_graph/node/unpersisted.rb', line 6 def deferred_create_cache @deferred_create_cache ||= {} end |
#deferred_nodes_for_association(association_name) ⇒ Object
16 17 18 |
# File 'lib/active_graph/node/unpersisted.rb', line 16 def deferred_nodes_for_association(association_name) deferred_create_cache[association_name.to_sym] ||= [] end |
#pending_deferred_creations? ⇒ Boolean
20 21 22 |
# File 'lib/active_graph/node/unpersisted.rb', line 20 def pending_deferred_creations? !deferred_create_cache.values.all?(&:empty?) end |