Class: Emailvision::Relation
- Inherits:
-
Object
- Object
- Emailvision::Relation
- Defined in:
- lib/emailvision/relation.rb
Overview
Relation is used for API-chained call
e.g. emv.get.campaign.last(:limit => 5).call
Instance Method Summary collapse
-
#call(*args) ⇒ Object
Trigger the API call.
-
#initialize(instance, http_verb) ⇒ Relation
constructor
A new instance of Relation.
- #method_missing(method, *args) ⇒ Object
Constructor Details
#initialize(instance, http_verb) ⇒ Relation
Returns a new instance of Relation.
9 10 11 12 13 14 |
# File 'lib/emailvision/relation.rb', line 9 def initialize(instance, http_verb) @instance = instance @http_verb = http_verb @uri = [] @options = {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
26 27 28 29 30 |
# File 'lib/emailvision/relation.rb', line 26 def method_missing(method, *args) @uri << method.to_s.camelize(:lower) @options.merge! extract_args(args) self end |
Instance Method Details
#call(*args) ⇒ Object
Trigger the API call
21 22 23 24 |
# File 'lib/emailvision/relation.rb', line 21 def call(*args) @options.merge! extract_args(args) @instance.call @http_verb, @uri.join('/'), @options end |