Module: Facteur::BaseAddresseeModel::ClassMethods

Defined in:
lib/facteur/base_addressee_model.rb

Instance Method Summary collapse

Instance Method Details

#default_mailboxObject

return the default mailbox name if set, else return nil



28
29
30
# File 'lib/facteur/base_addressee_model.rb', line 28

def default_mailbox
  @mailboxes.select{ |mailbox| mailbox[:default] == true }.first[:name]
end

#has_mailbox?(name) ⇒ Boolean

check if a mailbox is defined

Returns:

  • (Boolean)


20
21
22
23
24
25
# File 'lib/facteur/base_addressee_model.rb', line 20

def has_mailbox?(name)
  @mailboxes.each do |mailbox|
    return true if mailbox[:name] == name
  end
  false
end

#mailbox(name, options = {}) ⇒ Object

Define a mailbox. The following options are available:

:default

defines the default mailbox. You must choose one default mailbox



8
9
10
11
12
# File 'lib/facteur/base_addressee_model.rb', line 8

def mailbox(name, options={})
  mailbox = {:name => name}
  mailbox.merge! options
  mailboxes << mailbox
end

#mailboxesObject

Returns the mailboxes defined for the class



15
16
17
# File 'lib/facteur/base_addressee_model.rb', line 15

def mailboxes
  @mailboxes ||= []
end