-
Notifications
You must be signed in to change notification settings - Fork 45
Ampers: Kaitlin Forsman #28
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
base: master
Are you sure you want to change the base?
Conversation
…Order.all method and tests
…and got it to pass :D
…to match online order and pass written test
…hange the method from the Online class
…ote and rewrote code to pass test
…ll the nils with ArgumentErrors
Grocery StoreWhat We're Looking For
|
| end | ||
| # returns array of all orders in the CSV | ||
| def self.all | ||
| @@all_orders = [] |
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.
If you're resetting @@all_orders each time self.all is called, why make it a class variable. It's just as good as a local variable.
| return order | ||
| end | ||
| end | ||
| raise ArgumentError |
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.
You should probably not raise an ArgumentError here. It would make sense to return nil when you can't find such an order.
| super(id, products) | ||
| @customer_id = customer_id | ||
| @customer = Customer.find(@customer_id) | ||
| if status.class == Symbol |
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 if/else is unnecessary as symbols also have a to_sym method
| # inherited method from order class that adds 10 for shipping to the total | ||
| # if order is greater than 0 | ||
| def total | ||
| if super == 0 |
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.
well done!
| # method to return an array of all orders from a single customers | ||
| # from the input of their customer id | ||
| def self.find_by_customer(customer_id) | ||
| Customer.find(customer_id) |
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.
Why have this line?
Grocery Store
Congratulations! You're submitting your assignment.
Comprehension Questions
raise ArgumentError?.all&.findmethods class methods? Why not instance methods?