class ActiveRecord::TimeScope::TimeProxy

Public Class Methods

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

Public Instance Methods

after(time, opts = {}) click to toggle source
# File lib/active_record/time_scope/time_proxy.rb, line 16
def after(time, opts = {})
  operator = opts[:include_equal].to_s != '' ? '<=' : '<'
  @model.where("? #{operator} #{@column_name}", time)
end
before(time, opts = {}) click to toggle source
# File lib/active_record/time_scope/time_proxy.rb, line 11
def before(time, opts = {})
  operator = opts[:include_equal].to_s != '' ? '<=' : '<'
  @model.where("#{@column_name} #{operator} ?", time)
end
within(from, to, from_opts = {}, to_opts = {}) click to toggle source
# File lib/active_record/time_scope/time_proxy.rb, line 21
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_name} AND #{@column_name} #{to_operator} ?", from, to)
end