Class: MarketoAPI::ClientProxy
- Inherits:
-
Object
- Object
- MarketoAPI::ClientProxy
- Extended by:
- Forwardable
- Defined in:
- lib/marketo_api/client_proxy.rb
Overview
The ClientProxy is the base class for implementing Marketo APIs in a fluent manner. When a descendant class is implemented, a method will be added to MarketoAPI::Client based on the descendant class name that will provide an initialized instance of the descendant class using the MarketoAPI::Client instance.
This base class does not provide any useful functionality for consumers of MarketoAPI, and is primarily provided for common functionality.
As an example, MarketoAPI::Client#campaigns was generated when MarketoAPI::Campaigns was inherited from MarketoAPI::ClientProxy. It returns an instance of MarketoAPI::Campaigns intialized with the MarketoAPI::Client that generated it.
Class Method Summary collapse
-
.inherited(klass) ⇒ Object
Generates a new method on MarketoAPI::Client based on the inherited class name.
Instance Method Summary collapse
-
#initialize(client) ⇒ ClientProxy
constructor
A new instance of ClientProxy.
Constructor Details
#initialize(client) ⇒ ClientProxy
Returns a new instance of ClientProxy.
33 34 35 |
# File 'lib/marketo_api/client_proxy.rb', line 33 def initialize(client) @client = client end |
Class Method Details
.inherited(klass) ⇒ Object
Generates a new method on MarketoAPI::Client based on the inherited class name.
22 23 24 25 26 27 28 29 30 |
# File 'lib/marketo_api/client_proxy.rb', line 22 def inherited(klass) name = klass.name.split(/::/).last.downcase.to_sym MarketoAPI::Client.class_eval " def \#{name}\n @\#{name} ||= \#{klass}.new(self)\n end\n EOS\nend\n" |