Class: Sendmark::Mail
- Inherits:
-
Object
- Object
- Sendmark::Mail
- Defined in:
- lib/sendmark/mail.rb
Instance Attribute Summary collapse
-
#css_parser ⇒ Object
readonly
Returns the value of attribute css_parser.
Instance Method Summary collapse
- #deliver ⇒ Object
- #delivery_method(method, settings = {}) ⇒ Object
-
#initialize(args = {}, &block) ⇒ Mail
constructor
A new instance of Mail.
- #mail ⇒ Object
- #rendered_html ⇒ Object
Constructor Details
#initialize(args = {}, &block) ⇒ Mail
Returns a new instance of Mail.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/sendmark/mail.rb', line 21 def initialize(args = {}, &block) args.each do |k, v| setter = "#{k}=" send(setter, v) if respond_to?(setter) end if block_given? instance_eval(&block) end unless css.nil? @css_parser = CssParser.new @css_parser.load_string! css end end |
Instance Attribute Details
#css_parser ⇒ Object (readonly)
Returns the value of attribute css_parser.
3 4 5 |
# File 'lib/sendmark/mail.rb', line 3 def css_parser @css_parser end |
Instance Method Details
#deliver ⇒ Object
43 44 45 46 47 |
# File 'lib/sendmark/mail.rb', line 43 def deliver delivery_mail = mail delivery_mail.delivery_method(@method, @settings) delivery_mail.deliver end |
#delivery_method(method, settings = {}) ⇒ Object
37 38 39 40 41 |
# File 'lib/sendmark/mail.rb', line 37 def delivery_method(method, settings = {}) @method = method @settings = settings self end |
#mail ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/sendmark/mail.rb', line 49 def mail html = rendered_html mail = ::Mail.new(to: to, from: from, subject: subject) html_part = ::Mail::Part.new do content_type "text/html; charset=UTF-8" body html end mail.html_part = html_part mail end |