Module: Daterange::ClassMethods

Defined in:
lib/acts_as_daterange/daterange.rb

Instance Method Summary collapse

Instance Method Details

#active_at(time) ⇒ Object



17
18
19
20
21
# File 'lib/acts_as_daterange/daterange.rb', line 17

def active_at(time)
  where("(#{start_column} IS NULL OR #{start_column} <= :time) AND 
        (#{expire_column} IS NULL OR #{expire_column} > :time)",
        time: time)
end

#active_nowObject



28
29
30
# File 'lib/acts_as_daterange/daterange.rb', line 28

def active_now
  active_at(Time.now)
end

#expire_columnObject



9
10
11
# File 'lib/acts_as_daterange/daterange.rb', line 9

def expire_column
  daterange_config[:expire_column]
end

#inactive_at(time) ⇒ Object



23
24
25
26
# File 'lib/acts_as_daterange/daterange.rb', line 23

def inactive_at(time)
  where("#{start_column} > :time OR #{expire_column} < :time",
        time: time)
end

#inactive_nowObject



32
33
34
# File 'lib/acts_as_daterange/daterange.rb', line 32

def inactive_now
  inactive_at(Time.now)
end

#start_columnObject



13
14
15
# File 'lib/acts_as_daterange/daterange.rb', line 13

def start_column
  daterange_config[:start_column]
end