2017-02-11 16:45:27 +05:30
|
|
|
class RootRouteConstraint
|
|
|
|
|
def initialize
|
2017-04-16 10:42:46 +05:30
|
|
|
@current = Conference.where('start_date <= ? AND end_date >= ?', Date.current, Date.current)
|
|
|
|
|
@current = Conference.where('start_date = ?', Date.current + 1) if @current.blank?
|
2017-02-11 16:45:27 +05:30
|
|
|
end
|
|
|
|
|
|
2017-03-19 09:17:31 +05:30
|
|
|
##
|
|
|
|
|
# Checks if only one conference is live and has a public splashpage
|
|
|
|
|
# If any conference is live it checks how many live conferences are there
|
|
|
|
|
# ====Returns
|
|
|
|
|
# * +true+ -> only one conferene is live AND the conference has public splashpage
|
|
|
|
|
# * +false+ -> no or more than one conferences are live or the only live conferece has no public splashpage
|
2017-02-11 16:45:27 +05:30
|
|
|
def matches?(*)
|
2017-04-16 10:42:46 +05:30
|
|
|
@current.present? && @current.first.splashpage.present? && @current.count == 1 && @current.first.splashpage.public?
|
2017-02-11 16:45:27 +05:30
|
|
|
end
|
|
|
|
|
end
|