Posted By

garethhrees on 11/30/10


Tagged


Versions (?)

Case with boolean methods?


 / Published in: Ruby
 

  1. # class Cart
  2. def add_to_cart
  3. @items << current_item if current_item.passes_all_checks?
  4. end
  5.  
  6.  
  7. # class CartItem
  8. def passes_all_checks?
  9. self.on_sale?
  10. self.in_stock?
  11. self.available_to_customer_type?
  12. end

Report this snippet  

You need to login to post a comment.