diff --git a/lib/business/calendar.rb b/lib/business/calendar.rb index 4815c7d..8946c05 100644 --- a/lib/business/calendar.rb +++ b/lib/business/calendar.rb @@ -57,6 +57,10 @@ def initialize(config) set_extra_working_dates(config[:extra_working_dates]) set_working_days(config[:working_days]) set_holidays(config[:holidays]) + + unless (@holidays & @extra_working_dates).none? + raise ArgumentError, 'Holidays cannot be extra working dates' + end end # Return true if the date given is a business day (typically that means a @@ -197,8 +201,6 @@ def parse_dates(dates) # Internal method for assigning holidays from a calendar config. def set_holidays(holidays) @holidays = parse_dates(holidays) - return if (@holidays & @extra_working_dates).none? - raise ArgumentError, 'Holidays cannot be extra working dates' end def set_extra_working_dates(extra_working_dates)