Class: Mailchimp::STS
Class Attribute Summary collapse
-
.api_key ⇒ Object
Returns the value of attribute api_key.
Attributes inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
- #call(method, params = {}) ⇒ Object
-
#initialize(api_key = nil, extra_params = {}) ⇒ STS
constructor
A new instance of STS.
- #method_missing(method, *args) ⇒ Object
Methods inherited from Base
#dc_from_api_key, #valid_api_key?
Constructor Details
#initialize(api_key = nil, extra_params = {}) ⇒ STS
Returns a new instance of STS.
7 8 9 10 11 12 13 14 15 |
# File 'lib/mailchimp/sts.rb', line 7 def initialize(api_key = nil, extra_params = {}) super(api_key,{ :apikey => api_key, :options => { :track_opens => true, :track_clicks => true } }.merge(extra_params)) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
21 22 23 24 |
# File 'lib/mailchimp/sts.rb', line 21 def method_missing(method, *args) method = method.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase } #Thanks for the gsub, Rails call(method, *args) end |
Class Attribute Details
.api_key ⇒ Object
Returns the value of attribute api_key.
27 28 29 |
# File 'lib/mailchimp/sts.rb', line 27 def api_key @api_key end |
Class Method Details
.method_missing(sym, *args, &block) ⇒ Object
29 30 31 |
# File 'lib/mailchimp/sts.rb', line 29 def method_missing(sym, *args, &block) new(self.api_key).send(sym, *args, &block) end |
Instance Method Details
#call(method, params = {}) ⇒ Object
17 18 19 |
# File 'lib/mailchimp/sts.rb', line 17 def call(method, params = {}) super("#{base_api_url}#{method}",params.merge({:apikey => @api_key})) end |