Module: ActiveRecord::ConnectionAdapters::Quoting

Defined in:
lib/activerecord-time/extension_4_2.rb,
lib/activerecord-time/extension_until_4_1.rb

Instance Method Summary collapse

Instance Method Details

#_quote_with_time_of_day(value) ⇒ Object



4
5
6
7
# File 'lib/activerecord-time/extension_4_2.rb', line 4

def _quote_with_time_of_day(value)
  return "'#{value}'" if value.is_a?(TimeOfDay)
  _quote_without_time_of_day(value)
end

#_type_cast_with_time_of_day(value) ⇒ Object



9
10
11
12
# File 'lib/activerecord-time/extension_4_2.rb', line 9

def _type_cast_with_time_of_day(value)
  return value.to_s if value.is_a?(TimeOfDay)
  _type_cast_without_time_of_day(value)
end

#quote_with_time_of_day(value, column = nil) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/activerecord-time/extension_until_4_1.rb', line 6

def quote_with_time_of_day(value, column = nil)
  if column && column.type == :time && value.is_a?(Integer)
    value = TimeOfDay.new(value / 3600, (value % 3600) / 60, value % 60)
  end
  return "'#{value.to_s(:db)}'" if value.is_a?(TimeOfDay)
  quote_without_time_of_day(value, column)
end

#type_cast_with_time_of_day(value, column) ⇒ Object



16
17
18
19
# File 'lib/activerecord-time/extension_until_4_1.rb', line 16

def type_cast_with_time_of_day(value, column)
  return value.to_s if value.is_a?(TimeOfDay)
  type_cast_without_time_of_day(value, column)
end