Skip to content

Commit

Permalink
Merge ca7e40d into a6e89cd
Browse files Browse the repository at this point in the history
  • Loading branch information
rhymes committed Feb 16, 2017
2 parents a6e89cd + ca7e40d commit 7d7d66e
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 228 deletions.
27 changes: 1 addition & 26 deletions lib/parse/client.rb
Expand Up @@ -164,13 +164,7 @@ def user(data)
# Module methods
# ------------------------------------------------------------
class << self
# A singleton client for use by methods in Object.
# Always use Parse.client to retrieve the client object.
@client = nil

# Factory to create instances of Client.
# This should be preferred over Parse.init which uses a singleton
# client object for all API calls.
def create(data = {}, &blk)
options = defaults = {
application_id: ENV['PARSE_APPLICATION_ID'],
Expand All @@ -181,15 +175,7 @@ def create(data = {}, &blk)

Client.new(options, &blk)
end

# DEPRECATED: Please use create instead.
# Initialize the singleton instance of Client which is used
# by all API methods. Parse.init must be called before saving
# or retrieving any objects.
def init(data = {}, &blk)
warn '[DEPRECATION] `init` is deprecated. Please use `create` instead.'
@@client = create(data, &blk)
end
alias :init :create

# A convenience method for using global.json
def init_from_cloud_code(path = '../config/global.json', app_name = nil)
Expand All @@ -201,17 +187,6 @@ def init_from_cloud_code(path = '../config/global.json', app_name = nil)
create(application_id: application_id, master_key: master_key)
end

# Used mostly for testing. Lets you delete the api key global vars.
def destroy
@@client = nil
self
end

def client
raise ParseError, 'API not initialized' unless @@client
@@client
end

# Perform a simple retrieval of a simple object, or all objects of a
# given class. If object_id is supplied, a single object will be
# retrieved. If object_id is not supplied, then all objects of the
Expand Down
4 changes: 1 addition & 3 deletions lib/parse/error.rb
@@ -1,8 +1,6 @@
# encoding: utf-8
module Parse
# Base exception class for errors thrown by the Parse
# client library. ParseError will be raised by any
# network operation if Parse.init() has not been called.
# Base exception class for errors thrown by the Parse client library.
class ParseError < StandardError
end

Expand Down
2 changes: 1 addition & 1 deletion lib/parse/object.rb
Expand Up @@ -18,7 +18,7 @@ def initialize(class_name, data = nil, client = nil)
@class_name = class_name
@op_fields = {}
parse data if data
@client = client || Parse.client
@client = client
end

def eql?(other)
Expand Down
12 changes: 12 additions & 0 deletions test/test_client_create.rb
Expand Up @@ -197,4 +197,16 @@ def test_get_method_override
refute client.get_method_override
refute client.session.builder.handlers.include? Faraday::GetMethodOverride
end

def test_no_api_keys_error
skip('this is skipped in the meantime because env vars override everything')
VCR.use_cassette('test_no_api_keys_error') do
assert_raises(Parse::ParseError) do
client = Parse.create(master_key: nil, api_key: nil)
fake = client.object('shouldNeverExist')
fake['foo'] = 'bar'
fake.save
end
end
end
end
182 changes: 0 additions & 182 deletions test/test_client_init.rb

This file was deleted.

16 changes: 0 additions & 16 deletions test/test_init.rb

This file was deleted.

0 comments on commit 7d7d66e

Please sign in to comment.