Module: Parse
- Defined in:
- lib/parse/model/core/errors.rb,
lib/parse/query.rb,
lib/parse/stack.rb,
lib/parse/client.rb,
lib/parse/api/all.rb,
lib/parse/api/push.rb,
lib/parse/webhooks.rb,
lib/parse/api/batch.rb,
lib/parse/api/files.rb,
lib/parse/api/hooks.rb,
lib/parse/api/users.rb,
lib/parse/model/acl.rb,
lib/parse/api/config.rb,
lib/parse/api/schema.rb,
lib/parse/api/server.rb,
lib/parse/model/date.rb,
lib/parse/model/file.rb,
lib/parse/model/push.rb,
lib/parse/api/objects.rb,
lib/parse/model/bytes.rb,
lib/parse/model/model.rb,
lib/parse/stack/tasks.rb,
lib/parse/api/sessions.rb,
lib/parse/client/batch.rb,
lib/parse/model/object.rb,
lib/parse/api/aggregate.rb,
lib/parse/api/analytics.rb,
lib/parse/model/pointer.rb,
lib/parse/stack/railtie.rb,
lib/parse/stack/version.rb,
lib/parse/client/caching.rb,
lib/parse/client/request.rb,
lib/parse/model/geopoint.rb,
lib/parse/query/ordering.rb,
lib/parse/client/protocol.rb,
lib/parse/client/response.rb,
lib/parse/model/time_zone.rb,
lib/parse/query/operation.rb,
lib/parse/query/constraint.rb,
lib/parse/webhooks/payload.rb,
lib/parse/model/core/schema.rb,
lib/parse/query/constraints.rb,
lib/parse/model/classes/role.rb,
lib/parse/model/classes/user.rb,
lib/parse/model/core/actions.rb,
lib/parse/model/core/actions.rb,
lib/parse/model/core/builder.rb,
lib/parse/api/cloud_functions.rb,
lib/parse/client/body_builder.rb,
lib/parse/model/core/fetching.rb,
lib/parse/model/core/querying.rb,
lib/parse/client/authentication.rb,
lib/parse/model/classes/product.rb,
lib/parse/model/classes/session.rb,
lib/parse/model/core/properties.rb,
lib/parse/webhooks/registration.rb,
lib/parse/model/associations/has_one.rb,
lib/parse/model/classes/installation.rb,
lib/parse/model/associations/has_many.rb,
lib/parse/model/associations/belongs_to.rb,
lib/parse/model/associations/collection_proxy.rb,
lib/parse/model/associations/pointer_collection_proxy.rb,
lib/parse/model/associations/relation_collection_proxy.rb
Overview
This module is mainly all the basic orm operations. To support batching actions, we use temporary Request objects have contain the operation to be performed (in some cases). This allows to group a list of Request methods, into a batch for sending all at once to Parse.
Defined Under Namespace
Modules: API, Associations, Core, Middleware, Properties, Protocol, Stack Classes: ACL, BatchOperation, Bytes, Client, CollectionProxy, Constraint, DataType, Date, Error, File, GeoPoint, Hyperdrive, Installation, Model, Object, Operation, Order, Pointer, PointerCollectionProxy, Product, Push, Query, RecordNotSaved, RelationAction, RelationCollectionProxy, Request, Response, Role, Session, TimeZone, User, Webhooks
Class Attribute Summary collapse
- .logging ⇒ Boolean readonly
Sets Middleware::BodyBuilder logging.
Class Method Summary collapse
- .auto_generate_models! ⇒ Array
Create all Parse::Object subclasses, including their properties and inferred associations by importing the schema for the remote collections in a Parse application.
- .auto_upgrade! ⇒ Object
Perform a non-destructive upgrade of all your Parse schemas in the backend based on the property definitions of your local Object subclasses.
- .batch(reqs = nil) ⇒ BatchOperation
Create a new batch operation.
- .cache ⇒ Moneta::Transformer, Moneta::Expires
The shared cache for the default client connection.
- .call_function(name, body = {}, **opts) ⇒ Object
Helper method to call cloud functions and get results.
- .classify(className) ⇒ Class
Find a corresponding Parse::Object subclass for this string or symbol.
- .client(conn = :default) ⇒ Parse::Client
Helper method to get the default Parse client.
- .config(conn = :default) ⇒ Hash
Retrieve the App specific Parse configuration parameters.
- .config!(conn = :default) ⇒ Hash
Force fetch updated Parse configuration.
- .registered_classes ⇒ Array
An array of registered Parse::Object subclasses.
- .schema(className) ⇒ Hash
Fetch the schema for a specific collection name.
- .schemas ⇒ Array<Hash>
The list of all schemas for this application.
- .set_config(field, value, conn = :default) ⇒ Hash
Set a parameter in the Parse configuration for an application.
- .setup(opts = {}) { ... } ⇒ Client
Helper method that users should call to setup the client stack.
- .trigger_job(name, body = {}, **opts) ⇒ Object
Helper method to trigger cloud jobs and get results.
- .update_config(params, conn = :default) ⇒ Hash
Set a key value pairs in the Parse configuration for an application.
- .use_shortnames! ⇒ Object
Alias shorter names of core Parse class names.
Class Attribute Details
.logging ⇒ Boolean
Sets Parse::Middleware::BodyBuilder logging. You may specify `:debug` for additional verbosity.
18 19 20 | # File 'lib/parse/client/body_builder.rb', line 18 def self.logging Parse::Middleware::BodyBuilder.logging end |
Class Method Details
.auto_generate_models! ⇒ Array
Create all Parse::Object subclasses, including their properties and inferred associations by importing the schema for the remote collections in a Parse application. Uses the default configured client.
15 16 17 18 19 | # File 'lib/parse/model/core/builder.rb', line 15 def self.auto_generate_models! Parse.schemas.map do |schema| Parse::Model::Builder.build!(schema) end end |
.auto_upgrade! ⇒ Object
Perform a non-destructive upgrade of all your Parse schemas in the backend based on the property definitions of your local Object subclasses.
56 57 58 59 60 61 62 | # File 'lib/parse/model/object.rb', line 56 def self.auto_upgrade! klassModels = Parse::Object.descendants klassModels.sort_by(&:parse_class).each do |klass| yield(klass) if block_given? klass.auto_upgrade! end end |
.batch(reqs = nil) ⇒ BatchOperation
Create a new batch operation.
11 12 13 | # File 'lib/parse/client/batch.rb', line 11 def self.batch(reqs = nil) BatchOperation.new(reqs) end |
.cache ⇒ Moneta::Transformer, Moneta::Expires
The shared cache for the default client connection. This is useful if you want to also utilize the same cache store for other purposes in your application. This should normally be a Moneta unified cache interface.
104 105 106 | # File 'lib/parse/client.rb', line 104 def self.cache @shared_cache ||= Parse::Client.client(:default).cache end |
.call_function(name, body = {}, **opts) ⇒ Object
Helper method to call cloud functions and get results.
607 608 609 610 611 612 | # File 'lib/parse/client.rb', line 607 def self.call_function(name, body = {}, **opts) conn = opts[:session] || opts[:client] || :default response = Parse::Client.client(conn).call_function(name, body) return response if opts[:raw].present? response.error? ? nil : response.result["result"] end |
.classify(className) ⇒ Class
Find a corresponding Parse::Object subclass for this string or symbol
15 16 17 | # File 'lib/parse/model/model.rb', line 15 def self.classify(className) Parse::Model.find_class className.to_parse_class end |
.client(conn = :default) ⇒ Parse::Client
Helper method to get the default Parse client.
94 95 96 | # File 'lib/parse/client.rb', line 94 def self.client(conn = :default) Parse::Client.client(conn) end |
.config(conn = :default) ⇒ Hash
Retrieve the App specific Parse configuration parameters. The configuration for a connection is cached after the first request. Use the bang version to force update from the Parse backend.
57 58 59 | # File 'lib/parse/client.rb', line 57 def self.config(conn = :default) Parse::Client.client(conn).config end |
.config!(conn = :default) ⇒ Hash
Force fetch updated Parse configuration
87 88 89 | # File 'lib/parse/client.rb', line 87 def self.config!(conn = :default) Parse::Client.client(conn).config! end |
.registered_classes ⇒ Array
Returns an array of registered Parse::Object subclasses.
37 38 39 | # File 'lib/parse/model/object.rb', line 37 def self.registered_classes Parse::Object.descendants.map(&:parse_class).uniq end |
.schema(className) ⇒ Hash
Fetch the schema for a specific collection name.
50 51 52 | # File 'lib/parse/model/object.rb', line 50 def self.schema(className) client.schema(className).result end |
.schemas ⇒ Array<Hash>
Returns the list of all schemas for this application.
42 43 44 | # File 'lib/parse/model/object.rb', line 42 def self.schemas client.schemas.results end |
.set_config(field, value, conn = :default) ⇒ Hash
Set a parameter in the Parse configuration for an application.
69 70 71 | # File 'lib/parse/client.rb', line 69 def self.set_config(field, value, conn = :default) Parse::Client.client(conn).update_config({ field => value }) end |
.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.
582 583 584 585 586 587 588 | # File 'lib/parse/client.rb', line 582 def self.setup(opts = {}) if block_given? Parse::Client.new(opts, &Proc.new) else Parse::Client.new(opts) end end |
.trigger_job(name, body = {}, **opts) ⇒ Object
Helper method to trigger cloud jobs and get results.
595 596 597 598 599 600 | # File 'lib/parse/client.rb', line 595 def self.trigger_job(name, body = {}, **opts) conn = opts[:session] || opts[:client] || :default response = Parse::Client.client(conn).trigger_job(name, body) return response if opts[:raw].present? response.error? ? nil : response.result["result"] end |
.update_config(params, conn = :default) ⇒ Hash
Set a key value pairs in the Parse configuration for an application.
80 81 82 | # File 'lib/parse/client.rb', line 80 def self.update_config(params, conn = :default) Parse::Client.client(conn).update_config(params) end |
.use_shortnames! ⇒ Object
Alias shorter names of core Parse class names. Ex, alias Parse::User to User, Parse::Installation to Installation, etc.
66 67 68 | # File 'lib/parse/model/object.rb', line 66 def self.use_shortnames! require_relative "shortnames" end |