module Mastodon::REST::Utils

Public Instance Methods

array_param(key, values) click to toggle source

Format an array of values into a query param @param key [Symbol] @param values [Enumerable] @return [Array]

# 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 = {}) click to toggle source

@param request_method [Symbol] @param path [String] @param options [Hash]

# File lib/mastodon/rest/utils.rb, line 11
def perform_request(request_method, path, options = {})
  Mastodon::REST::Request.new(self, request_method, path, options).perform
end
perform_request_with_collection(request_method, path, options, klass) click to toggle source

@param request_method [Symbol] @param path [String] @param options [Hash] @param klass [Class]

# File lib/mastodon/rest/utils.rb, line 28
def perform_request_with_collection(request_method, path, options, klass)
  response = perform_request(request_method, path, options)
  Mastodon::Collection.new(response, klass)
end
perform_request_with_object(request_method, path, options, klass) click to toggle source

@param request_method [Symbol] @param path [String] @param options [Hash] @param klass [Class]

# File lib/mastodon/rest/utils.rb, line 19
def perform_request_with_object(request_method, path, options, klass)
  response = perform_request(request_method, path, options)
  klass.new(response)
end