Class: Spree::Wishlist
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Spree::Wishlist
- Defined in:
- app/models/spree/wishlist.rb
Class Method Summary collapse
Instance Method Summary collapse
- #can_be_read_by?(user) ⇒ Boolean
- #include?(variant_id) ⇒ Boolean
- #is_default=(value) ⇒ Object
- #is_public? ⇒ Boolean
- #to_param ⇒ Object
Class Method Details
.get_by_param(param) ⇒ Object
16 17 18 |
# File 'app/models/spree/wishlist.rb', line 16 def self.get_by_param(param) Spree::Wishlist.find_by_access_hash(param) end |
Instance Method Details
#can_be_read_by?(user) ⇒ Boolean
20 21 22 |
# File 'app/models/spree/wishlist.rb', line 20 def can_be_read_by?(user) !self.is_private? || user == self.user end |
#include?(variant_id) ⇒ Boolean
8 9 10 |
# File 'app/models/spree/wishlist.rb', line 8 def include?(variant_id) self.wished_products.map(&:variant_id).include? variant_id.to_i end |
#is_default=(value) ⇒ Object
24 25 26 27 28 29 |
# File 'app/models/spree/wishlist.rb', line 24 def is_default=(value) self['is_default'] = value if self.is_default? Spree::Wishlist.update_all({:is_default => false}, ["id != ? AND is_default = ? AND user_id = ?", self.id, true, self.user_id]) end end |
#is_public? ⇒ Boolean
31 32 33 |
# File 'app/models/spree/wishlist.rb', line 31 def is_public? !self.is_private? end |
#to_param ⇒ Object
12 13 14 |
# File 'app/models/spree/wishlist.rb', line 12 def to_param self.access_hash end |