Method: Parse.setup

Defined in:
lib/parse/client.rb

.setup(opts = {}) { ... } ⇒ Client

Helper method that users should call to setup the client stack. A block can be passed in order to do additional client configuration. To connect to a Parse server, you will need a minimum of an application_id, an api_key and a server_url. To connect to the server endpoint, you use the setup method below.

Examples:

Parse.setup app_id: "YOUR_APP_ID",
            api_key: "YOUR_REST_API_KEY",
            master_key: "YOUR_MASTER_KEY", # optional
            server_url: 'https://localhost:1337/parse' #default

Parameters:

  • opts (Hash) (defaults to: {})

    a set of connection options to configure the client.

Options Hash (opts):

  • :server_url (String)

    The server url of your Parse Server if you are not using the hosted Parse service. By default it will use ENV if available, otherwise fallback to Parse::Protocol::SERVER_URL.

  • :app_id (String)

    The Parse application id. Defaults to ENV.

  • :api_key (String)

    Your Parse REST API Key. Defaults to ENV.

  • :master_key (String)

    The Parse application master key (optional). If this key is set, it will be sent on every request sent by the client and your models. Defaults to ENV.

  • :logging (Boolean)

    It provides you additional logging information of requests and responses. If set to the special symbol of :debug, it will provide additional payload data in the log messages. This option affects the logging performed by Parse::Middleware::BodyBuilder.

  • :adapter (Object)

    The connection adapter. By default it uses the Faraday.default_adapter which is Net/HTTP.

  • :cache (Moneta::Transformer, Moneta::Expires)

    A caching adapter of type Moneta::Transformer or Moneta::Expires that will be used by the caching middleware Parse::Middleware::Caching. Caching queries and object fetches can help improve the performance of your application, even if it is for a few seconds. Only successful GET object fetches and non-empty result queries will be cached by default. You may set the default expiration time with the expires option. At any point in time you may clear the cache by calling the Parse::Client#clear_cache! method on the client connection. See Moneta.

  • :expires (Integer)

    Sets the default cache expiration time (in seconds) for successful non-empty GET requests when using the caching middleware. The default value is 3 seconds. If :expires is set to 0, caching will be disabled. You can always clear the current state of the cache using the clear_cache! method on your Parse::Client instance.

  • :faraday (Hash)

    You may pass a hash of options that will be passed to the Faraday constructor.

Yields:

  • the block for additional configuration with Faraday middleware.

Returns:

  • (Client)

    a new instance of Client

See Also:



577
578
579
580
581
582
583
# File 'lib/parse/client.rb', line 577

def self.setup(opts = {})
  if block_given?
    Parse::Client.new(opts, &Proc.new)
  else
    Parse::Client.new(opts)
  end
end