mad_mimi_mailer 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,5 @@
1
1
  module MadMimiMailable
2
+ SINGLE_SEND_URL = 'https://madmimi.com/mailer'
2
3
 
3
4
  def self.included(base)
4
5
  base.extend(ClassMethods)
@@ -38,9 +39,13 @@ module MadMimiMailable
38
39
  end
39
40
  end
40
41
 
41
- module ClassMethods
42
+ module ClassMethods
43
+ attr_accessor :method_prefix
44
+
42
45
  def method_missing(method_symbol, *parameters)
43
- if method_symbol.id2name.match(/^deliver_([_a-z]\w*)/)
46
+ if method_prefix && method_symbol.id2name.match(/^deliver_(#{method_prefix}_[_a-z]\w*)/)
47
+ deliver_mimi_mail($1, *parameters)
48
+ elsif method_prefix.nil? && method_symbol.id2name.match(/^deliver_([_a-z]\w*)/)
44
49
  deliver_mimi_mail($1, *parameters)
45
50
  else
46
51
  super
@@ -75,7 +80,7 @@ module MadMimiMailable
75
80
  params = {
76
81
  'username' => MadMimiMailer.api_settings[:username],
77
82
  'api_key' => MadMimiMailer.api_settings[:api_key],
78
- 'promotion_name' => mail.promotion || method.to_s.sub(/^mimi_/, ''),
83
+ 'promotion_name' => mail.promotion || method.to_s.sub(/^#{method_prefix}_/, ''),
79
84
  'recipients' => serialize(mail.recipients),
80
85
  'subject' => mail.subject,
81
86
  'bcc' => serialize(mail.bcc || MadMimiMailer.default_parameters[:bcc]),
@@ -5,8 +5,7 @@ require "net/https"
5
5
  require "mad_mimi_mailable"
6
6
 
7
7
  class MadMimiMailer < ActionMailer::Base
8
- VERSION = '0.1.0'
9
- SINGLE_SEND_URL = 'https://madmimi.com/mailer'
8
+ VERSION = '0.1.1'
10
9
 
11
10
  @@api_settings = {}
12
11
  cattr_accessor :api_settings
@@ -15,20 +14,12 @@ class MadMimiMailer < ActionMailer::Base
15
14
  cattr_accessor :default_parameters
16
15
 
17
16
  include MadMimiMailable
18
-
19
- class << self
20
- def method_missing(method_symbol, *parameters)
21
- if method_symbol.id2name.match(/^deliver_(mimi_[_a-z]\w*)/)
22
- deliver_mimi_mail($1, *parameters)
23
- else
24
- super
25
- end
26
- end
27
- end
17
+ self.method_prefix = "mimi"
28
18
 
29
19
  class ValidationError < StandardError; end
30
20
  end
31
21
 
22
+
32
23
  # Adding the response body to HTTPResponse errors to provide better error messages.
33
24
  module Net
34
25
  class HTTPResponse
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 0
9
- version: 0.1.0
8
+ - 1
9
+ version: 0.1.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Dave Hoover