Module: AddThis::Requests
- Included in:
- Client
- Defined in:
- lib/add_this/requests.rb
Class Method Summary collapse
-
.requests(*args) ⇒ Object
requests method.
Class Method Details
.requests(*args) ⇒ Object
requests method
Defines the get request for all the methods by splitting the method name and the underscore to keep things dry as well allows your to pass a hash for all the query params
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/add_this/requests.rb', line 16 def self.requests(*args) args.each do |arg| define_method arg do |*| metric, dimension = arg.to_s.split("_") connection.get do |req| req.url("/analytics/1.0/pub/#{metric}/#{dimension}.json", [0] || {}) end.body end end end |