class ActiveRecord::TimeScope::TimeRangeProxy

Public Class Methods

new(model, column_name1, column_name2) click to toggle source
# File lib/active_record/time_scope/time_range_proxy.rb, line 6
def initialize(model, column_name1, column_name2)
  @model = model
  @column_name1 = column_name1
  @column_name2 = column_name2
end

Public Instance Methods

after(time, opts = {}) click to toggle source
# File lib/active_record/time_scope/time_range_proxy.rb, line 17
def after(time, opts = {})
  operator = opts[:include_equal].to_s != '' ? '<=' : '<'
  @model.where("? #{operator} #{@column_name1} AND ? #{operator} #{@column_name2}", time, time)
end
at(dt, opts = {}) click to toggle source
# File lib/active_record/time_scope/time_range_proxy.rb, line 28
def at(dt, opts = {})
  operator = opts[:include_equal].to_s != '' ? '<=' : '<'
  @model.where("#{@column_name1} #{operator} ? AND ? #{operator} #{@column_name2}", dt, dt)
end
Also aliased as: on
before(time, opts = {}) click to toggle source
# File lib/active_record/time_scope/time_range_proxy.rb, line 12
def before(time, opts = {})
  operator = opts[:include_equal].to_s != '' ? '<=' : '<'
  @model.where("#{@column_name1} #{operator} ? AND #{@column_name2} #{operator} ?", time, time)
end
on(dt, opts = {})
Alias for: at
within(from, to, from_opts = {}, to_opts = {}) click to toggle source
# File lib/active_record/time_scope/time_range_proxy.rb, line 22
def within(from, to, from_opts = {}, to_opts = {})
  from_operator = from_opts[:include_equal].to_s != '' ? '<=' : '<'
  to_operator = to_opts[:include_equal].to_s != '' ? '<=' : '<'
  @model.where("? #{from_operator} #{@column_name1} AND #{@column_name2} #{to_operator} ?", from, to)
end