Module: ZTK::DSL::Core::Relations::HasMany Private
- Defined in:
- lib/ztk/dsl/core/relations/has_many.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Defined Under Namespace
Modules: ClassMethods
Class Method Summary (collapse)
- + (Object) included(base) private
Instance Method Summary (collapse)
- - (Object) get_has_many_reference(key) private
- - (Object) has_many_references private
- - (Object) save_has_many_references private
- - (Object) set_has_many_reference(key, value) private
Class Method Details
+ (Object) included(base)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
7 8 9 10 11 12 |
# File 'lib/ztk/dsl/core/relations/has_many.rb', line 7 def self.included(base) base.class_eval do base.add_relation(:has_many) base.send(:extend, ZTK::DSL::Core::Relations::HasMany::ClassMethods) end end |
Instance Method Details
- (Object) get_has_many_reference(key)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
18 19 20 21 22 23 24 |
# File 'lib/ztk/dsl/core/relations/has_many.rb', line 18 def get_has_many_reference(key) if has_many_references.key?(key) has_many_references[key] else has_many_references[key] ||= [] end end |
- (Object) has_many_references
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
14 15 16 |
# File 'lib/ztk/dsl/core/relations/has_many.rb', line 14 def has_many_references @has_many_references ||= {} end |
- (Object) save_has_many_references
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
32 33 34 35 36 37 38 |
# File 'lib/ztk/dsl/core/relations/has_many.rb', line 32 def save_has_many_references has_many_references.each do |key, dataset| dataset.each do |data| # do something to store the data somewhere end end end |
- (Object) set_has_many_reference(key, value)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
26 27 28 29 30 |
# File 'lib/ztk/dsl/core/relations/has_many.rb', line 26 def set_has_many_reference(key, value) dataset = get_has_many_reference(key) dataset.clear dataset.concat(value) end |