class DbFuel::Modeling::KeyedColumn

Connects a hash key to a SQL column. By default if a column is not given then its key will be used for both. The general use case for this is for mapping objects to SQL and SQL to objects.

Attributes

column[R]
key[R]

Public Class Methods

new(key:, column: '') click to toggle source
# File lib/db_fuel/modeling/keyed_column.rb, line 20
def initialize(key:, column: '')
  raise ArgumentError, 'key is required' if key.blank?

  @column = column.present? ? column.to_s : key.to_s
  @key    = key.to_s

  freeze
end