Class: ActsAsTable::Mapper::HasOne
- Defined in:
- lib/acts_as_table/mapper.rb
Overview
ActsAsTable mapper object for an instance of the BelongsTo class for the :has_one
macro.
Instance Method Summary collapse
-
#initialize(row_model, column_model_by_key, record_model, method_name, target) {|has_one| ... } ⇒ ActsAsTable::Mapper::HasOne
constructor
Returns a new ActsAsTable mapper object an instance of the BelongsTo class for the
:has_one
macro.
Constructor Details
#initialize(row_model, column_model_by_key, record_model, method_name, target) {|has_one| ... } ⇒ ActsAsTable::Mapper::HasOne
Returns a new ActsAsTable mapper object an instance of the BelongsTo class for the :has_one
macro.
176 177 178 179 180 181 182 183 184 185 186 |
# File 'lib/acts_as_table/mapper.rb', line 176 def initialize(row_model, column_model_by_key, record_model, method_name, target, &block) @row_model, @column_model_by_key, @record_model = row_model, column_model_by_key, record_model @row_model.belongs_tos.build(macro: 'has_one', method_name: method_name) do |belongs_to| belongs_to.source_record_model = @record_model belongs_to.target_record_model = target.send(:instance_variable_get, :@record_model) end super(&block) end |