Class: ActsAsTable::Mapper::RecordModel
- Defined in:
- lib/acts_as_table/mapper.rb
Overview
ActsAsTable mapper object for an instance of the RecordModel class.
Instance Method Summary collapse
-
#attribute(method_name, position_or_key = nil, **options) {|lense| ... } ⇒ ActsAsTable::Mapper::Lense
Returns a new ActsAsTable mapper object an instance of the Lense class.
-
#belongs_to(method_name, target) {|belongs_to| ... } ⇒ ActsAsTable::Mapper::BelongsTo
Returns a new ActsAsTable mapper object an instance of the BelongsTo class for the
:belongs_to
macro. -
#foreign_key(method_name, position_or_key = nil, **options) {|foreign_key| ... } ⇒ ActsAsTable::Mapper::ForeignKey
Returns a new ActsAsTable mapper object an instance of the ForeignKey class.
-
#has_and_belongs_to_many(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. -
#has_many(method_name, *targets) {|has_many| ... } ⇒ ActsAsTable::Mapper::HasMany
Returns a new ActsAsTable mapper object an instance of the HasMany class for the
:has_many
macro. -
#has_one(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. -
#initialize(row_model, column_model_by_key, class_name) {|record_model| ... } ⇒ ActsAsTable::Mapper::RecordModel
constructor
Returns a new ActsAsTable mapper object an instance of the RecordModel class.
-
#primary_key(position_or_key = nil, method_name = 'id') {|primary_key| ... } ⇒ ActsAsTable::Mapper::PrimaryKey
Returns a new ActsAsTable mapper object an instance of the PrimaryKey class.
Constructor Details
#initialize(row_model, column_model_by_key, class_name) {|record_model| ... } ⇒ ActsAsTable::Mapper::RecordModel
Returns a new ActsAsTable mapper object an instance of the RecordModel class.
315 316 317 318 319 320 321 |
# File 'lib/acts_as_table/mapper.rb', line 315 def initialize(row_model, column_model_by_key, class_name, &block) @row_model, @column_model_by_key = row_model, column_model_by_key @record_model = row_model.record_models.build(class_name: class_name) super(&block) end |
Instance Method Details
#attribute(method_name, position_or_key = nil, **options) {|lense| ... } ⇒ ActsAsTable::Mapper::Lense
Returns a new ActsAsTable mapper object an instance of the Lense class.
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 |
# File 'lib/acts_as_table/mapper.rb', line 306 class RecordModel < Base # Returns a new ActsAsTable mapper object an instance of the {ActsAsTable::RecordModel} class. # # @param [ActsAsTable::RowModel] row_model # @param [Hash<Symbol, ActsAsTable::ColumnModel>] column_model_by_key # @param [#to_s] class_name # @yieldparam [ActsAsTable::Mapper::RecordModel] record_model # @yieldreturn [void] # @return [ActsAsTable::Mapper::RecordModel] def initialize(row_model, column_model_by_key, class_name, &block) @row_model, @column_model_by_key = row_model, column_model_by_key @record_model = row_model.record_models.build(class_name: class_name) super(&block) end { attribute: :Lense, belongs_to: :BelongsTo, foreign_key: :ForeignKey, has_and_belongs_to_many: :HasAndBelongsToMany, has_many: :HasMany, has_one: :HasOne, primary_key: :PrimaryKey, }.each do |method_name, const_name| define_method(method_name) do |*args, &block| ActsAsTable::Mapper.const_get(const_name).new(@row_model, @column_model_by_key, @record_model, *args, &block) end end end |
#belongs_to(method_name, target) {|belongs_to| ... } ⇒ ActsAsTable::Mapper::BelongsTo
Returns a new ActsAsTable mapper object an instance of the BelongsTo class for the :belongs_to
macro.
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 |
# File 'lib/acts_as_table/mapper.rb', line 306 class RecordModel < Base # Returns a new ActsAsTable mapper object an instance of the {ActsAsTable::RecordModel} class. # # @param [ActsAsTable::RowModel] row_model # @param [Hash<Symbol, ActsAsTable::ColumnModel>] column_model_by_key # @param [#to_s] class_name # @yieldparam [ActsAsTable::Mapper::RecordModel] record_model # @yieldreturn [void] # @return [ActsAsTable::Mapper::RecordModel] def initialize(row_model, column_model_by_key, class_name, &block) @row_model, @column_model_by_key = row_model, column_model_by_key @record_model = row_model.record_models.build(class_name: class_name) super(&block) end { attribute: :Lense, belongs_to: :BelongsTo, foreign_key: :ForeignKey, has_and_belongs_to_many: :HasAndBelongsToMany, has_many: :HasMany, has_one: :HasOne, primary_key: :PrimaryKey, }.each do |method_name, const_name| define_method(method_name) do |*args, &block| ActsAsTable::Mapper.const_get(const_name).new(@row_model, @column_model_by_key, @record_model, *args, &block) end end end |
#foreign_key(method_name, position_or_key = nil, **options) {|foreign_key| ... } ⇒ ActsAsTable::Mapper::ForeignKey
Returns a new ActsAsTable mapper object an instance of the ForeignKey class.
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 |
# File 'lib/acts_as_table/mapper.rb', line 306 class RecordModel < Base # Returns a new ActsAsTable mapper object an instance of the {ActsAsTable::RecordModel} class. # # @param [ActsAsTable::RowModel] row_model # @param [Hash<Symbol, ActsAsTable::ColumnModel>] column_model_by_key # @param [#to_s] class_name # @yieldparam [ActsAsTable::Mapper::RecordModel] record_model # @yieldreturn [void] # @return [ActsAsTable::Mapper::RecordModel] def initialize(row_model, column_model_by_key, class_name, &block) @row_model, @column_model_by_key = row_model, column_model_by_key @record_model = row_model.record_models.build(class_name: class_name) super(&block) end { attribute: :Lense, belongs_to: :BelongsTo, foreign_key: :ForeignKey, has_and_belongs_to_many: :HasAndBelongsToMany, has_many: :HasMany, has_one: :HasOne, primary_key: :PrimaryKey, }.each do |method_name, const_name| define_method(method_name) do |*args, &block| ActsAsTable::Mapper.const_get(const_name).new(@row_model, @column_model_by_key, @record_model, *args, &block) end end end |
#has_and_belongs_to_many(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.
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 |
# File 'lib/acts_as_table/mapper.rb', line 306 class RecordModel < Base # Returns a new ActsAsTable mapper object an instance of the {ActsAsTable::RecordModel} class. # # @param [ActsAsTable::RowModel] row_model # @param [Hash<Symbol, ActsAsTable::ColumnModel>] column_model_by_key # @param [#to_s] class_name # @yieldparam [ActsAsTable::Mapper::RecordModel] record_model # @yieldreturn [void] # @return [ActsAsTable::Mapper::RecordModel] def initialize(row_model, column_model_by_key, class_name, &block) @row_model, @column_model_by_key = row_model, column_model_by_key @record_model = row_model.record_models.build(class_name: class_name) super(&block) end { attribute: :Lense, belongs_to: :BelongsTo, foreign_key: :ForeignKey, has_and_belongs_to_many: :HasAndBelongsToMany, has_many: :HasMany, has_one: :HasOne, primary_key: :PrimaryKey, }.each do |method_name, const_name| define_method(method_name) do |*args, &block| ActsAsTable::Mapper.const_get(const_name).new(@row_model, @column_model_by_key, @record_model, *args, &block) end end end |
#has_many(method_name, *targets) {|has_many| ... } ⇒ ActsAsTable::Mapper::HasMany
Returns a new ActsAsTable mapper object an instance of the HasMany class for the :has_many
macro.
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 |
# File 'lib/acts_as_table/mapper.rb', line 306 class RecordModel < Base # Returns a new ActsAsTable mapper object an instance of the {ActsAsTable::RecordModel} class. # # @param [ActsAsTable::RowModel] row_model # @param [Hash<Symbol, ActsAsTable::ColumnModel>] column_model_by_key # @param [#to_s] class_name # @yieldparam [ActsAsTable::Mapper::RecordModel] record_model # @yieldreturn [void] # @return [ActsAsTable::Mapper::RecordModel] def initialize(row_model, column_model_by_key, class_name, &block) @row_model, @column_model_by_key = row_model, column_model_by_key @record_model = row_model.record_models.build(class_name: class_name) super(&block) end { attribute: :Lense, belongs_to: :BelongsTo, foreign_key: :ForeignKey, has_and_belongs_to_many: :HasAndBelongsToMany, has_many: :HasMany, has_one: :HasOne, primary_key: :PrimaryKey, }.each do |method_name, const_name| define_method(method_name) do |*args, &block| ActsAsTable::Mapper.const_get(const_name).new(@row_model, @column_model_by_key, @record_model, *args, &block) end end end |
#has_one(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.
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 |
# File 'lib/acts_as_table/mapper.rb', line 306 class RecordModel < Base # Returns a new ActsAsTable mapper object an instance of the {ActsAsTable::RecordModel} class. # # @param [ActsAsTable::RowModel] row_model # @param [Hash<Symbol, ActsAsTable::ColumnModel>] column_model_by_key # @param [#to_s] class_name # @yieldparam [ActsAsTable::Mapper::RecordModel] record_model # @yieldreturn [void] # @return [ActsAsTable::Mapper::RecordModel] def initialize(row_model, column_model_by_key, class_name, &block) @row_model, @column_model_by_key = row_model, column_model_by_key @record_model = row_model.record_models.build(class_name: class_name) super(&block) end { attribute: :Lense, belongs_to: :BelongsTo, foreign_key: :ForeignKey, has_and_belongs_to_many: :HasAndBelongsToMany, has_many: :HasMany, has_one: :HasOne, primary_key: :PrimaryKey, }.each do |method_name, const_name| define_method(method_name) do |*args, &block| ActsAsTable::Mapper.const_get(const_name).new(@row_model, @column_model_by_key, @record_model, *args, &block) end end end |
#primary_key(position_or_key = nil, method_name = 'id') {|primary_key| ... } ⇒ ActsAsTable::Mapper::PrimaryKey
Returns a new ActsAsTable mapper object an instance of the PrimaryKey class.
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 |
# File 'lib/acts_as_table/mapper.rb', line 306 class RecordModel < Base # Returns a new ActsAsTable mapper object an instance of the {ActsAsTable::RecordModel} class. # # @param [ActsAsTable::RowModel] row_model # @param [Hash<Symbol, ActsAsTable::ColumnModel>] column_model_by_key # @param [#to_s] class_name # @yieldparam [ActsAsTable::Mapper::RecordModel] record_model # @yieldreturn [void] # @return [ActsAsTable::Mapper::RecordModel] def initialize(row_model, column_model_by_key, class_name, &block) @row_model, @column_model_by_key = row_model, column_model_by_key @record_model = row_model.record_models.build(class_name: class_name) super(&block) end { attribute: :Lense, belongs_to: :BelongsTo, foreign_key: :ForeignKey, has_and_belongs_to_many: :HasAndBelongsToMany, has_many: :HasMany, has_one: :HasOne, primary_key: :PrimaryKey, }.each do |method_name, const_name| define_method(method_name) do |*args, &block| ActsAsTable::Mapper.const_get(const_name).new(@row_model, @column_model_by_key, @record_model, *args, &block) end end end |