Class: Spree::Wishlist

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/spree/wishlist.rb

Class Method Summary collapse

Instance Method Summary collapse

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

Returns:

  • (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

Returns:

  • (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

Returns:

  • (Boolean)


31
32
33
# File 'app/models/spree/wishlist.rb', line 31

def is_public?
  !self.is_private?
end

#to_paramObject



12
13
14
# File 'app/models/spree/wishlist.rb', line 12

def to_param
  self.access_hash
end