-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ports - Jessica #27
base: master
Are you sure you want to change the base?
Ports - Jessica #27
Conversation
…ull up list of rooms
…esk has access to everything
…gument error if room is not available
…and reformatting line lengths
…g tests, refactor and clean, simplify arguments for blocks
HotelWhat We're Looking For
|
@@ -0,0 +1,2 @@ | |||
class AvailabilityError < StandardError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Custom error class! 🎉
raise ArgumentError, "Block doesn't exist" unless block | ||
end | ||
|
||
def validate_size(number_of_rooms:) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would consider moving this code into Block
since the FrontDesk
doesn't really need to know about the maximum number of rooms a block can have.
end | ||
|
||
def validate_size(number_of_rooms:) | ||
max_rooms_for_block = 5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a constant, probably also in Block
. The reason a constant would be useful here is if we change the rules about how many rooms can be used in a block there's a clear single place to change it.
raise ArgumentError, "Reservation must be at least one day long" if check_in >= check_out | ||
end | ||
|
||
def validate_date_arguments(check_in: nil, check_out: nil, nights: nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The date validation also probably doesn't want to live in FrontDesk
since that's unrelated to its job of managing the high level state of the hotel. (There are other methods that might want to be moved out as well but which ones would depend on your specific solution.)
There are two main ways to avoid repeating this in Reservation
and Block
:
- Make an
Interval
orDateRange
class that's responsible for validation/comparison of dates. - Make a parent class for both
Block
andReservation
that handles the above functionality.
rooms.select { |room| room.available?(nights: nights) } | ||
end | ||
|
||
def create_block(check_in:, check_out:, room_collection: nil, number_of_rooms: nil, room_rate:) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of this logic probably wants to live in Block
. This method is rather coupled to the state of FrontDesk
though so the challenging part would be figuring out how little you could get away with passing into the Block
class.
Hotel
Congratulations! You're submitting your assignment!
Comprehension Questions