Class: Unavailability::UnavailableDates::Remove
- Inherits:
-
Object
- Object
- Unavailability::UnavailableDates::Remove
- Defined in:
- lib/unavailability/unavailable_dates/remove.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(dateable, from, to) ⇒ Remove
constructor
A new instance of Remove.
- #unavailable_dates ⇒ Object
Constructor Details
#initialize(dateable, from, to) ⇒ Remove
Returns a new instance of Remove.
4 5 6 7 8 9 10 11 |
# File 'lib/unavailability/unavailable_dates/remove.rb', line 4 def initialize(dateable, from, to) @dateable = dateable @from = from @to = to raise ArgumentError.new('from has to be a Date') unless @from.is_a?(Date) raise ArgumentError.new('to has to be a Date') unless @to.is_a?(Date) end |
Instance Method Details
#call ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/unavailability/unavailable_dates/remove.rb', line 17 def call if overlappings.empty? # do nothing else overlappings.each do |unavailability| update(unavailability, from, to) end end dateable end |
#unavailable_dates ⇒ Object
13 14 15 |
# File 'lib/unavailability/unavailable_dates/remove.rb', line 13 def unavailable_dates dateable.unavailable_dates end |