class RailsAdmin::AbstractModel::StatementBuilder::FilteringDuration

Public Class Methods

new(operator, value) click to toggle source
# File lib/rails_admin/abstract_model.rb, line 226
def initialize(operator, value)
  @value = value
  @operator = operator
end

Public Instance Methods

between() click to toggle source
# File lib/rails_admin/abstract_model.rb, line 259
def between
  [@value[1], @value[2]]
end
default() click to toggle source
# File lib/rails_admin/abstract_model.rb, line 263
def default
  [default_date, default_date]
end
get_duration() click to toggle source
# File lib/rails_admin/abstract_model.rb, line 231
def get_duration
  case @operator
  when 'between'   then between
  when 'today'     then today
  when 'yesterday' then yesterday
  when 'this_week' then this_week
  when 'last_week' then last_week
  else default
  end
end
last_week() click to toggle source
# File lib/rails_admin/abstract_model.rb, line 254
def last_week
  [1.week.ago.to_date.beginning_of_week,
   1.week.ago.to_date.end_of_week]
end
this_week() click to toggle source
# File lib/rails_admin/abstract_model.rb, line 250
def this_week
  [Date.today.beginning_of_week, Date.today.end_of_week]
end
today() click to toggle source
# File lib/rails_admin/abstract_model.rb, line 242
def today
  [Date.today, Date.today]
end
yesterday() click to toggle source
# File lib/rails_admin/abstract_model.rb, line 246
def yesterday
  [Date.yesterday, Date.yesterday]
end

Private Instance Methods

default_date() click to toggle source
# File lib/rails_admin/abstract_model.rb, line 269
def default_date
  Array.wrap(@value).first
end