Class: Maily::Mailer
- Inherits:
-
Object
- Object
- Maily::Mailer
- Defined in:
- lib/maily/mailer.rb
Instance Attribute Summary collapse
-
#emails ⇒ Object
Returns the value of attribute emails.
-
#klass ⇒ Object
Returns the value of attribute klass.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #emails_list ⇒ Object
- #find_email(email_name) ⇒ Object
- #hide_email(*email_names) ⇒ Object
-
#initialize(name) ⇒ Mailer
constructor
A new instance of Mailer.
- #register_hook(email_name, *args) ⇒ Object
- #total_emails ⇒ Object
Constructor Details
#initialize(name) ⇒ Mailer
Returns a new instance of Mailer.
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/maily/mailer.rb', line 6 def initialize(name) self.name = name self.klass = name.camelize.constantize self.emails = {} parse_emails self.class.collection ||= {} self.class.collection[name] = self end |
Instance Attribute Details
#emails ⇒ Object
Returns the value of attribute emails.
4 5 6 |
# File 'lib/maily/mailer.rb', line 4 def emails @emails end |
#klass ⇒ Object
Returns the value of attribute klass.
4 5 6 |
# File 'lib/maily/mailer.rb', line 4 def klass @klass end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/maily/mailer.rb', line 4 def name @name end |
Class Method Details
.all ⇒ Object
17 18 19 20 |
# File 'lib/maily/mailer.rb', line 17 def self.all Maily.load_emails_and_hooks if collection.nil? collection end |
.find(mailer_name) ⇒ Object
26 27 28 |
# File 'lib/maily/mailer.rb', line 26 def self.find(mailer_name) all[mailer_name] end |
.list ⇒ Object
22 23 24 |
# File 'lib/maily/mailer.rb', line 22 def self.list all.values.sort_by(&:name) end |
Instance Method Details
#emails_list ⇒ Object
34 35 36 |
# File 'lib/maily/mailer.rb', line 34 def emails_list emails.values.sort_by(&:name) end |
#find_email(email_name) ⇒ Object
30 31 32 |
# File 'lib/maily/mailer.rb', line 30 def find_email(email_name) emails[email_name.to_s] end |
#hide_email(*email_names) ⇒ Object
47 48 49 50 51 |
# File 'lib/maily/mailer.rb', line 47 def hide_email(*email_names) email_names.each do |email_name| emails.delete(email_name.to_s) end end |
#register_hook(email_name, *args) ⇒ Object
42 43 44 45 |
# File 'lib/maily/mailer.rb', line 42 def register_hook(email_name, *args) email = find_email(email_name) || add_email(email_name) email && email.register_hook(args) end |
#total_emails ⇒ Object
38 39 40 |
# File 'lib/maily/mailer.rb', line 38 def total_emails emails.size end |