class StrategyStore::Strategy::Column

Constants

CAST_MAPPING

Should be updated in Rails 5 TODO : Must be cleaned (binary, deciman_without_scale, …?) TODO : Manage Array & Hash

Attributes

default[RW]
name[RW]
null[RW]
type[RW]

Public Class Methods

new(name, type, options = {}) click to toggle source

Instantiates a new column .

name is the strategy column’s name. type is the type of the columns, such as string. options is various information about the column (limit, scale, precision, null, default) null determines if this column allows NULL values.

# File lib/strategy_store/strategy/column.rb, line 33
def initialize(name, type, options = {})
  @cast_type = CAST_MAPPING.fetch(type).new(options.slice(:limit, :scale, :precision))
  @name    = name
  @type    = type
  @default = options[:default]
  @null    = options[:default] || true
end

Public Instance Methods

cast(value) click to toggle source

Cast a value using ActiveRecord::Type .

# File lib/strategy_store/strategy/column.rb, line 42
def cast(value)
  @cast_type.send(:cast_value, value)
end