Module: Mailthis::Mailer::InstanceMethods
- Defined in:
- lib/mailthis/mailer.rb
Instance Method Summary collapse
- #deliver(message = nil, &block) ⇒ Object
- #from(value = nil) ⇒ Object
- #initialize(&block) ⇒ Object
- #logger(value = nil) ⇒ Object
- #smtp_auth(value = nil) ⇒ Object
- #smtp_helo(value = nil) ⇒ Object
- #smtp_port(value = nil) ⇒ Object
- #smtp_pw(value = nil) ⇒ Object
- #smtp_server(value = nil) ⇒ Object
- #smtp_user(value = nil) ⇒ Object
- #valid? ⇒ Boolean
- #validate! ⇒ Object
Instance Method Details
#deliver(message = nil, &block) ⇒ Object
102 103 104 |
# File 'lib/mailthis/mailer.rb', line 102 def deliver( = nil, &block) raise NotImplementedError end |
#from(value = nil) ⇒ Object
76 77 78 79 |
# File 'lib/mailthis/mailer.rb', line 76 def from(value = nil) @from = value if !value.nil? @from end |
#initialize(&block) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/mailthis/mailer.rb', line 38 def initialize(&block) @nil_settings = nil @smtp_auth = DEFAULT_AUTH @logger = NullLogger.new self.instance_eval(&block) if block end |
#logger(value = nil) ⇒ Object
81 82 83 84 |
# File 'lib/mailthis/mailer.rb', line 81 def logger(value = nil) @logger = value if !value.nil? @logger end |
#smtp_auth(value = nil) ⇒ Object
71 72 73 74 |
# File 'lib/mailthis/mailer.rb', line 71 def smtp_auth(value = nil) @smtp_auth = value.to_s if !value.nil? @smtp_auth end |
#smtp_helo(value = nil) ⇒ Object
46 47 48 49 |
# File 'lib/mailthis/mailer.rb', line 46 def smtp_helo(value = nil) @smtp_helo = value if !value.nil? @smtp_helo end |
#smtp_port(value = nil) ⇒ Object
56 57 58 59 |
# File 'lib/mailthis/mailer.rb', line 56 def smtp_port(value = nil) @smtp_port = value if !value.nil? @smtp_port end |
#smtp_pw(value = nil) ⇒ Object
66 67 68 69 |
# File 'lib/mailthis/mailer.rb', line 66 def smtp_pw(value = nil) @smtp_pw = value if !value.nil? @smtp_pw end |
#smtp_server(value = nil) ⇒ Object
51 52 53 54 |
# File 'lib/mailthis/mailer.rb', line 51 def smtp_server(value = nil) @smtp_server = value if !value.nil? @smtp_server end |
#smtp_user(value = nil) ⇒ Object
61 62 63 64 |
# File 'lib/mailthis/mailer.rb', line 61 def smtp_user(value = nil) @smtp_user = value if !value.nil? @smtp_user end |
#valid? ⇒ Boolean
86 87 88 |
# File 'lib/mailthis/mailer.rb', line 86 def valid? !@nil_settings.nil? && @nil_settings.empty? end |
#validate! ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/mailthis/mailer.rb', line 90 def validate! @from = self.smtp_user if @from.nil? @nil_settings = [] REQUIRED_SETTINGS.each{ |s| @nil_settings << s if self.send(s).nil? } if !self.valid? raise(MailerError, "missing required settings: #{@nil_settings.join(', ')}") end self # for chaining end |