Module: Spree::Core::UserBanners

Included in:
User
Defined in:
lib/spree/core/user_banners.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



7
8
9
# File 'lib/spree/core/user_banners.rb', line 7

def self.included(base)
  base.preference :dismissed_banners, :string, :default => ''
end

Instance Method Details

#dismiss_banner(banner_id) ⇒ Object



16
17
18
# File 'lib/spree/core/user_banners.rb', line 16

def dismiss_banner(banner_id)
  self.preferred_dismissed_banners = dismissed_banner_ids.push(banner_id.to_sym).uniq.join(',')
end

#dismissed_banner?(banner_id) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/spree/core/user_banners.rb', line 20

def dismissed_banner?(banner_id)
  dismissed_banner_ids.include? banner_id.to_sym
end

#dismissed_banner_idsObject



11
12
13
14
# File 'lib/spree/core/user_banners.rb', line 11

def dismissed_banner_ids
  dismissed = self.preferred_dismissed_banners
  dismissed.split(',').map(&:to_sym)
end