Module: ArSync::ClassMethodsBase
- Included in:
- GraphSync::ClassMethods, TreeSync::ClassMethods
- Defined in:
- lib/ar_sync/class_methods.rb
Instance Method Summary collapse
- #_each_sync_child(&block) ⇒ Object
- #_each_sync_parent(&block) ⇒ Object
- #_sync_child_info(name) ⇒ Object
- #_sync_children_info ⇒ Object
- #_sync_parents_info ⇒ Object
- #_sync_self? ⇒ Boolean
- #sync_parent(parent, inverse_of:, only_to: nil) ⇒ Object
Instance Method Details
#_each_sync_child(&block) ⇒ Object
28 29 30 31 |
# File 'lib/ar_sync/class_methods.rb', line 28 def _each_sync_child(&block) _sync_children_info.each(&block) superclass._each_sync_child(&block) if superclass < ActiveRecord::Base end |
#_each_sync_parent(&block) ⇒ Object
23 24 25 26 |
# File 'lib/ar_sync/class_methods.rb', line 23 def _each_sync_parent(&block) _sync_parents_info.each(&block) superclass._each_sync_parent(&block) if superclass < ActiveRecord::Base end |
#_sync_child_info(name) ⇒ Object
17 18 19 20 21 |
# File 'lib/ar_sync/class_methods.rb', line 17 def _sync_child_info(name) info = _sync_children_info[name] return info if info superclass._sync_child_info name if superclass < ActiveRecord::Base end |
#_sync_children_info ⇒ Object
13 14 15 |
# File 'lib/ar_sync/class_methods.rb', line 13 def _sync_children_info @_sync_children_info ||= {} end |
#_sync_parents_info ⇒ Object
9 10 11 |
# File 'lib/ar_sync/class_methods.rb', line 9 def _sync_parents_info @_sync_parents_info ||= [] end |
#_sync_self? ⇒ Boolean
5 6 7 |
# File 'lib/ar_sync/class_methods.rb', line 5 def _sync_self? instance_variable_defined? '@_sync_self' end |
#sync_parent(parent, inverse_of:, only_to: nil) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/ar_sync/class_methods.rb', line 33 def sync_parent(parent, inverse_of:, only_to: nil) _initialize_sync_callbacks _sync_parents_info << [ parent, { inverse_name: inverse_of, only_to: only_to } ] end |