Module: Mastodon::REST::Utils
- Included in:
- Accounts, Apps, Filters, Instances, Lists, Media, Notifications, Relationships, Search, Statuses, Suggestions, Timelines
- Defined in:
- lib/mastodon/rest/utils.rb
Instance Method Summary collapse
-
#array_param(key, values) ⇒ Array
Format an array of values into a query param.
- #perform_request(request_method, path, options = {}) ⇒ Object
- #perform_request_with_collection(request_method, path, options, klass) ⇒ Object
- #perform_request_with_object(request_method, path, options, klass) ⇒ Object
Instance Method Details
#array_param(key, values) ⇒ Array
Format an array of values into a query param
37 38 39 |
# File 'lib/mastodon/rest/utils.rb', line 37 def array_param(key, values) values.map.with_index { |value, _i| ["#{key}[]", value] } end |
#perform_request(request_method, path, options = {}) ⇒ Object
11 12 13 |
# File 'lib/mastodon/rest/utils.rb', line 11 def perform_request(request_method, path, = {}) Mastodon::REST::Request.new(self, request_method, path, ).perform end |
#perform_request_with_collection(request_method, path, options, klass) ⇒ Object
28 29 30 31 |
# File 'lib/mastodon/rest/utils.rb', line 28 def perform_request_with_collection(request_method, path, , klass) response = perform_request(request_method, path, ) Mastodon::Collection.new(response, klass) end |
#perform_request_with_object(request_method, path, options, klass) ⇒ Object
19 20 21 22 |
# File 'lib/mastodon/rest/utils.rb', line 19 def perform_request_with_object(request_method, path, , klass) response = perform_request(request_method, path, ) klass.new(response) end |