Class: Segment::API
Constant Summary collapse
- @@api_endpoint =
"https://api.segment.io/v2/"
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
Instance Method Summary collapse
-
#initialize(api_key) ⇒ API
constructor
A new instance of API.
- #post_with_api_key(method, params = {}) ⇒ Object
Constructor Details
#initialize(api_key) ⇒ API
Returns a new instance of API.
13 14 15 |
# File 'lib/rest-segment.rb', line 13 def initialize(api_key) @api_key = api_key end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object (private)
24 25 26 27 |
# File 'lib/rest-segment.rb', line 24 def method_missing(m, *args, &block) args = args.unshift(m) send :post_with_api_key, *args end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
10 11 12 |
# File 'lib/rest-segment.rb', line 10 def api_key @api_key end |
Instance Method Details
#post_with_api_key(method, params = {}) ⇒ Object
17 18 19 20 21 |
# File 'lib/rest-segment.rb', line 17 def post_with_api_key(method, params = {}) post api_endpoint(method), params.merge({ apiKey: self.api_key }) end |