Advertisement
Guest User

Untitled

a guest
May 25th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. module LocalRepository
  2. class LocalItem
  3.  
  4. attr_reader :name, :description, :price, :email, :image
  5. attr_accessor :id
  6.  
  7. def initialize(item_details)
  8. @name = item_details[:name]
  9. @description = item_details[:description]
  10. @price = item_details[:price]
  11. @email = item_details[:email]
  12. @image = item_details[:image]
  13. @id = item_details[:id]
  14. end
  15.  
  16. def save
  17. if self.valid?
  18. self
  19. else
  20. false
  21. end
  22. end
  23.  
  24. def valid?
  25. @id !=nil && @name != nil && @description != nil && @price != nil && @email != nil
  26. end
  27. end
  28. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement