Module: Facteur::BaseAddresseeModel::ClassMethods
- Defined in:
- lib/facteur/base_addressee_model.rb
Instance Method Summary collapse
-
#default_mailbox ⇒ Object
return the default mailbox name if set, else return nil.
-
#has_mailbox?(name) ⇒ Boolean
check if a mailbox is defined.
-
#mailbox(name, options = {}) ⇒ Object
Define a mailbox.
-
#mailboxes ⇒ Object
Returns the mailboxes defined for the class.
Instance Method Details
#default_mailbox ⇒ Object
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
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, ={}) mailbox = {:name => name} mailbox.merge! mailboxes << mailbox end |
#mailboxes ⇒ Object
Returns the mailboxes defined for the class
15 16 17 |
# File 'lib/facteur/base_addressee_model.rb', line 15 def mailboxes @mailboxes ||= [] end |