Class: ActsAsTable::Mapper::HasAndBelongsToMany
- Defined in:
- lib/acts_as_table/mapper.rb
Overview
ActsAsTable mapper object for an instance of the HasMany class for the :has_and_belongs_to_many
macro.
Instance Method Summary collapse
-
#initialize(row_model, column_model_by_key, record_model, method_name, *targets) {|has_and_belongs_to_many| ... } ⇒ ActsAsTable::Mapper::HasAndBelongsToMany
constructor
Returns a new ActsAsTable mapper object an instance of the HasMany class for the
:has_and_belongs_to_many
macro.
Constructor Details
#initialize(row_model, column_model_by_key, record_model, method_name, *targets) {|has_and_belongs_to_many| ... } ⇒ ActsAsTable::Mapper::HasAndBelongsToMany
Returns a new ActsAsTable mapper object an instance of the HasMany class for the :has_and_belongs_to_many
macro.
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/acts_as_table/mapper.rb', line 118 def initialize(row_model, column_model_by_key, record_model, method_name, *targets, &block) @row_model, @column_model_by_key, @record_model = row_model, column_model_by_key, record_model @row_model.has_manies.build(macro: 'has_and_belongs_to_many', method_name: method_name) do |has_many| has_many.source_record_model = @record_model targets.each_with_index do |target, index| has_many.has_many_targets.build(position: index + 1) do |has_many_target| has_many_target.record_model = target.send(:instance_variable_get, :@record_model) end end end super(&block) end |