lib/vrbo/calendar.rb in vrbo-2.0.1 vs lib/vrbo/calendar.rb in vrbo-2.1.0
- old
+ new
@@ -8,11 +8,11 @@
@days = {}
@available_dates = nil
end
def available_dates
- @available_dates ||= Date.today.upto(Date.today + 365).map { |date| date_if_available(date) }.compact
+ @available_dates ||= today.upto(today + 365).map { |date| date_if_available(date) }.compact
end
# @description exclusive, drops day from departure because bookings usually go on per nightly
def available?(arrival, depart, dates = nil)
dates = dates || available_dates
@@ -32,9 +32,13 @@
end
#
# Private
#
+
+ def today
+ @today ||= Date.respond_to?(:current) ? Date.current : Date.today
+ end
def date_if_available(date)
m = date.month.to_s
days[m] ||= collect_days_for_month(date)
date.to_s if days[m].include?(date.day.to_s)