module HstoreAccessor::TypeHelpers

Constants

TYPES

Public Class Methods

cast(type, value) click to toggle source
# File lib/hstore_accessor/active_record_4.2/type_helpers.rb, line 20
def cast(type, value)
  return nil if value.nil?

  case type
  when :string, :decimal
    value
  when :integer, :float, :datetime, :date, :boolean
    TYPES[type].new.type_cast_from_user(value)
  else value
    # Nothing.
  end
end
column_type_for(attribute, data_type) click to toggle source
# File lib/hstore_accessor/active_record_4.2/type_helpers.rb, line 16
def column_type_for(attribute, data_type)
  ActiveRecord::ConnectionAdapters::Column.new(attribute.to_s, nil, TYPES[data_type].new)
end