Class: ActiveRecord::ConnectionAdapters::MysqlAdapter::Fields::DateTime

Inherits:
Type::DateTime show all
Defined in:
lib/active_record/connection_adapters/mysql_adapter.rb

Overview

:nodoc:

Instance Attribute Summary

Attributes inherited from Type::Value

#limit, #precision, #scale

Instance Method Summary collapse

Methods inherited from Type::DateTime

#type, #type_cast_for_database

Methods included from Type::TimeValue

#klass, #type_cast_for_schema

Methods inherited from Type::Value

#==, #binary?, #changed?, #changed_in_place?, #hash, #initialize, #klass, #number?, #text?, #type, #type_cast_for_database, #type_cast_for_schema, #type_cast_from_database, #type_cast_from_user

Constructor Details

This class inherits a constructor from ActiveRecord::Type::Value

Instance Method Details

#cast_value(value) ⇒ Object



271
272
273
274
275
276
277
278
279
280
281
282
283
284
# File 'lib/active_record/connection_adapters/mysql_adapter.rb', line 271

def cast_value(value)
  if Mysql::Time === value
    new_time(
      value.year,
      value.month,
      value.day,
      value.hour,
      value.minute,
      value.second,
      value.second_part)
  else
    super
  end
end

#has_precision?Boolean

Returns:

  • (Boolean)


286
287
288
# File 'lib/active_record/connection_adapters/mysql_adapter.rb', line 286

def has_precision?
  precision || 0
end