Class: Wco::Tag

Inherits:
Object
  • Object
show all
Includes:
Mongoid::Document, Mongoid::Paranoia, Mongoid::Timestamps
Defined in:
app/models/wco/tag.rb

Constant Summary collapse

INBOX =
'inbox'
SPAM =
'spam'
NOT_SPAM =
'not-spam'
TRASH =
'trash'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.inboxObject



33
34
35
# File 'app/models/wco/tag.rb', line 33

def self.inbox
  find_or_create_by({ slug: INBOX })
end

.listObject



55
56
57
# File 'app/models/wco/tag.rb', line 55

def self.list
  [[nil,nil]] + all.order_by( slug: :asc ).map { |p| [ p.slug, p.id ] }
end

.not_spamObject



43
44
45
# File 'app/models/wco/tag.rb', line 43

def self.not_spam
  find_or_create_by({ slug: NOT_SPAM })
end

.spamObject



38
39
40
# File 'app/models/wco/tag.rb', line 38

def self.spam
  find_or_create_by({ slug: SPAM })
end

.trashObject



48
49
50
# File 'app/models/wco/tag.rb', line 48

def self.trash
  find_or_create_by({ slug: TRASH })
end

Instance Method Details

#to_sObject



52
53
54
# File 'app/models/wco/tag.rb', line 52

def to_s
  slug
end