Module: Twitter::API::Utils

Defined in:
lib/oii_twitter_goodies/extensions/twitter_api_utils.rb

Instance Method Summary collapse

Instance Method Details

#cursor_from_response(collection_name, klass, request_method, path, options, method_name) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/oii_twitter_goodies/extensions/twitter_api_utils.rb', line 19

def cursor_from_response(collection_name, klass, request_method, path, options, method_name)
  merge_default_cursor!(options)
  response = send(request_method.to_sym, path, options)
  if (response.class == Hash || response.class == BSON::OrderedHash) && !response.keys.include?(:body)
    Twitter::Cursor.from_response({:body => response}, collection_name.to_sym, klass, self, method_name, options)
  else
    Twitter::Cursor.from_response(response, collection_name.to_sym, klass, self, method_name, options)
  end
end

#object_from_response(klass, request_method, path, options = {}) ⇒ Object



14
15
16
17
# File 'lib/oii_twitter_goodies/extensions/twitter_api_utils.rb', line 14

def object_from_response(klass, request_method, path, options={})
  response = send(request_method.to_sym, path, options)
  return klass.from_response(response) || response
end

#objects_from_response(klass, request_method, path, options = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/oii_twitter_goodies/extensions/twitter_api_utils.rb', line 4

def objects_from_response(klass, request_method, path, options={})
  response = send(request_method.to_sym, path, options)
  if response.class == Hash && response[:body]
    response = response[:body]
    objects_from_array(klass, response)
  else
    return response
  end
end