Skip to content

Commit

Permalink
Fix the include equal operator
Browse files Browse the repository at this point in the history
  • Loading branch information
dtaniwaki committed Sep 28, 2014
1 parent 44d28e7 commit 0bac229
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions lib/active_record/time_scope/time_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ def initialize(model, column_name)
end

def before(time, opts = {})
operator = opts[:include_equal].to_s != '' ? '=<' : '<'
operator = opts[:include_equal].to_s != '' ? '<=' : '<'
@model.where("#{@column_name} #{operator} ?", time)
end

def after(time, opts = {})
operator = opts[:include_equal].to_s != '' ? '=<' : '<'
operator = opts[:include_equal].to_s != '' ? '<=' : '<'
@model.where("? #{operator} #{@column_name}", time)
end

def within(from, to, from_opts = {}, to_opts = {})
from_operator = from_opts[:include_equal].to_s != '' ? '=<' : '<'
to_operator = to_opts[:include_equal].to_s != '' ? '=<' : '<'
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
end
Expand Down
8 changes: 4 additions & 4 deletions lib/active_record/time_scope/time_range_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ def initialize(model, column_name1, column_name2)
end

def before(time, opts = {})
operator = opts[:include_equal].to_s != '' ? '=<' : '<'
operator = opts[:include_equal].to_s != '' ? '<=' : '<'
@model.where("#{@column_name1} #{operator} ? AND #{@column_name2} #{operator} ?", time, time)
end

def after(time, opts = {})
operator = opts[:include_equal].to_s != '' ? '=<' : '<'
operator = opts[:include_equal].to_s != '' ? '<=' : '<'
@model.where("? #{operator} #{@column_name1} AND ? #{operator} #{@column_name2}", time, time)
end

def within(from, to, from_opts = {}, to_opts = {})
from_operator = from_opts[:include_equal].to_s != '' ? '=<' : '<'
to_operator = to_opts[:include_equal].to_s != '' ? '=<' : '<'
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
end
Expand Down

0 comments on commit 0bac229

Please sign in to comment.