Class: MailChimp
- Inherits:
-
Object
- Object
- MailChimp
- Defined in:
- lib/mc/mailchimp.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(apikey, options = {}) ⇒ MailChimp
constructor
A new instance of MailChimp.
- #method_missing(method_name, *args) ⇒ Object
Constructor Details
#initialize(apikey, options = {}) ⇒ MailChimp
Returns a new instance of MailChimp.
5 6 7 8 9 10 11 |
# File 'lib/mc/mailchimp.rb', line 5 def initialize(apikey, ={}) @api = Gibbon::API.new(apikey) @api.throws_exceptions = true @options = @exporter = @api.get_exporter end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/mc/mailchimp.rb', line 13 def method_missing(method_name, *args) puts "DEBUG: Calling '#{method_name}(#{args})'..." if @options[:debug] category = method_name.to_s.split('_').first method = method_name.to_s.split('_')[1..-1].join('_') if category == "export" @exporter.__send__(method, *args) else if method == 'send' # handle wonk case of 'send' method @api.send(category).send(*args) else # had to change this from .send(method, *args) to .method_missing b/c of gibbon 1.0.3 @api.send(category).method_missing(method, *args) end end end |