class MR::TypeConverter
Constants
- TYPES
Public Class Methods
new(ar_column_class = nil)
click to toggle source
# File lib/mr/type_converter.rb, line 23 def initialize(ar_column_class = nil) @ar_column_class = ar_column_class || ActiveRecord::ConnectionAdapters::Column end
valid?(type)
click to toggle source
# File lib/mr/type_converter.rb, line 19 def self.valid?(type) TYPES.include?(type.to_sym) end
Public Instance Methods
binary(value)
click to toggle source
# File lib/mr/type_converter.rb, line 27 def binary(value) return if value.nil? @ar_column_class.binary_to_string(value) end
boolean(value)
click to toggle source
# File lib/mr/type_converter.rb, line 32 def boolean(value) return if value.nil? @ar_column_class.value_to_boolean(value) end
date(value)
click to toggle source
# File lib/mr/type_converter.rb, line 42 def date(value) return if value.nil? @ar_column_class.string_to_date(value) end
datetime(value)
click to toggle source
# File lib/mr/type_converter.rb, line 47 def datetime(value) return if value.nil? @ar_column_class.string_to_time(value) end
Also aliased as: timestamp
decimal(value)
click to toggle source
# File lib/mr/type_converter.rb, line 53 def decimal(value) return if value.nil? @ar_column_class.value_to_decimal(value) end
float(value)
click to toggle source
# File lib/mr/type_converter.rb, line 37 def float(value) return if value.nil? value.to_f end
integer(value)
click to toggle source
# File lib/mr/type_converter.rb, line 58 def integer(value) return if value.nil? @ar_column_class.value_to_integer(value) end
Also aliased as: primary_key
string(value)
click to toggle source
# File lib/mr/type_converter.rb, line 64 def string(value) return if value.nil? value.to_s end
time(value)
click to toggle source
# File lib/mr/type_converter.rb, line 78 def time(value) return if value.nil? @ar_column_class.string_to_dummy_time(value) end