Class: ActsAsTable::Mapper::Lense
- Defined in:
- lib/acts_as_table/mapper.rb
Overview
ActsAsTable mapper object for an instance of the Lense class.
Instance Method Summary collapse
-
#initialize(row_model, column_model_by_key, record_model, method_name, position_or_key = nil, **options) {|lense| ... } ⇒ ActsAsTable::Mapper::Lense
constructor
Returns a new ActsAsTable mapper object an instance of the Lense class.
Constructor Details
#initialize(row_model, column_model_by_key, record_model, method_name, position_or_key = nil, **options) {|lense| ... } ⇒ ActsAsTable::Mapper::Lense
Returns a new ActsAsTable mapper object an instance of the Lense class.
204 205 206 207 208 209 210 211 212 213 214 215 216 |
# File 'lib/acts_as_table/mapper.rb', line 204 def initialize(row_model, column_model_by_key, record_model, method_name, position_or_key = nil, **, &block) .assert_valid_keys(:default) @row_model, @column_model_by_key, @record_model = row_model, column_model_by_key, record_model @record_model.lenses.build(method_name: method_name, default_value: [:default]) do |lens| unless position_or_key.nil? lens.column_model = position_or_key.is_a?(::Symbol) ? @column_model_by_key[position_or_key] : @row_model.column_models[position_or_key - 1] end end super(&block) end |