Method: Parse::Client.setup
- Defined in:
- lib/parse/client.rb
.setup(opts = {}) { ... } ⇒ Client
Setup the a new client with the appropriate Parse app keys, middleware and options.
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 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 Middleware::BodyBuilder.
-
:adapter
(Object)
—
The connection adapter. By default it uses the
Faraday.default_adapterwhich 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 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 #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:
197 198 199 |
# File 'lib/parse/client.rb', line 197 def setup(opts = {}) @clients[:default] = self.new(opts, &Proc.new) end |