parse-stack 1.7.3 → 1.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/ruby.yml +36 -0
- data/.solargraph.yml +23 -0
- data/.travis.yml +6 -3
- data/Changes.md +84 -22
- data/Gemfile +14 -12
- data/Gemfile.lock +110 -60
- data/README.md +67 -24
- data/Rakefile +14 -14
- data/bin/parse-console +1 -0
- data/lib/parse/api/aggregate.rb +59 -0
- data/lib/parse/api/all.rb +2 -1
- data/lib/parse/api/analytics.rb +0 -3
- data/lib/parse/api/batch.rb +3 -5
- data/lib/parse/api/cloud_functions.rb +0 -3
- data/lib/parse/api/config.rb +0 -4
- data/lib/parse/api/files.rb +3 -7
- data/lib/parse/api/hooks.rb +4 -8
- data/lib/parse/api/objects.rb +9 -14
- data/lib/parse/api/push.rb +0 -4
- data/lib/parse/api/schema.rb +2 -6
- data/lib/parse/api/server.rb +4 -7
- data/lib/parse/api/sessions.rb +2 -5
- data/lib/parse/api/users.rb +9 -14
- data/lib/parse/client.rb +55 -50
- data/lib/parse/client/authentication.rb +29 -33
- data/lib/parse/client/batch.rb +8 -11
- data/lib/parse/client/body_builder.rb +19 -20
- data/lib/parse/client/caching.rb +23 -28
- data/lib/parse/client/protocol.rb +11 -12
- data/lib/parse/client/request.rb +4 -6
- data/lib/parse/client/response.rb +5 -7
- data/lib/parse/model/acl.rb +14 -12
- data/lib/parse/model/associations/belongs_to.rb +19 -24
- data/lib/parse/model/associations/collection_proxy.rb +328 -317
- data/lib/parse/model/associations/has_many.rb +22 -27
- data/lib/parse/model/associations/has_one.rb +7 -12
- data/lib/parse/model/associations/pointer_collection_proxy.rb +5 -13
- data/lib/parse/model/associations/relation_collection_proxy.rb +5 -9
- data/lib/parse/model/bytes.rb +8 -10
- data/lib/parse/model/classes/installation.rb +2 -4
- data/lib/parse/model/classes/product.rb +2 -5
- data/lib/parse/model/classes/role.rb +3 -5
- data/lib/parse/model/classes/session.rb +2 -5
- data/lib/parse/model/classes/user.rb +21 -17
- data/lib/parse/model/core/actions.rb +31 -46
- data/lib/parse/model/core/builder.rb +6 -6
- data/lib/parse/model/core/errors.rb +0 -1
- data/lib/parse/model/core/fetching.rb +45 -50
- data/lib/parse/model/core/properties.rb +53 -68
- data/lib/parse/model/core/querying.rb +292 -282
- data/lib/parse/model/core/schema.rb +89 -92
- data/lib/parse/model/date.rb +16 -23
- data/lib/parse/model/file.rb +171 -174
- data/lib/parse/model/geopoint.rb +12 -16
- data/lib/parse/model/model.rb +31 -37
- data/lib/parse/model/object.rb +58 -70
- data/lib/parse/model/pointer.rb +177 -176
- data/lib/parse/model/push.rb +8 -10
- data/lib/parse/model/shortnames.rb +1 -2
- data/lib/parse/model/time_zone.rb +3 -5
- data/lib/parse/query.rb +70 -37
- data/lib/parse/query/constraint.rb +4 -6
- data/lib/parse/query/constraints.rb +62 -20
- data/lib/parse/query/operation.rb +8 -11
- data/lib/parse/query/ordering.rb +45 -49
- data/lib/parse/stack.rb +15 -11
- data/lib/parse/stack/generators/rails.rb +28 -30
- data/lib/parse/stack/generators/templates/model.erb +5 -6
- data/lib/parse/stack/generators/templates/model_installation.rb +0 -1
- data/lib/parse/stack/generators/templates/model_role.rb +0 -1
- data/lib/parse/stack/generators/templates/model_session.rb +0 -1
- data/lib/parse/stack/generators/templates/model_user.rb +0 -1
- data/lib/parse/stack/generators/templates/parse.rb +9 -9
- data/lib/parse/stack/generators/templates/webhooks.rb +1 -2
- data/lib/parse/stack/railtie.rb +2 -4
- data/lib/parse/stack/tasks.rb +70 -86
- data/lib/parse/stack/version.rb +1 -1
- data/lib/parse/webhooks.rb +19 -26
- data/lib/parse/webhooks/payload.rb +26 -28
- data/lib/parse/webhooks/registration.rb +23 -31
- data/parse-stack.gemspec +28 -28
- data/parse-stack.png +0 -0
- metadata +27 -25
- data/.github/parse-ruby-sdk.png +0 -0
data/lib/parse/model/geopoint.rb
CHANGED
@@ -24,7 +24,7 @@ module Parse
|
|
24
24
|
#
|
25
25
|
class GeoPoint < Model
|
26
26
|
# The default attributes in a Parse GeoPoint hash.
|
27
|
-
ATTRIBUTES = {
|
27
|
+
ATTRIBUTES = { __type: :string, latitude: :float, longitude: :float }.freeze
|
28
28
|
|
29
29
|
# @return [Float] latitude value between -90.0 and 90.0
|
30
30
|
attr_accessor :latitude
|
@@ -47,9 +47,10 @@ module Parse
|
|
47
47
|
alias_method :lat, :latitude
|
48
48
|
alias_method :lng, :longitude
|
49
49
|
# @return [Model::TYPE_GEOPOINT]
|
50
|
-
def self.parse_class; TYPE_GEOPOINT; end
|
50
|
+
def self.parse_class; TYPE_GEOPOINT; end
|
51
51
|
# @return [Model::TYPE_GEOPOINT]
|
52
|
-
def parse_class; self.class.parse_class; end
|
52
|
+
def parse_class; self.class.parse_class; end
|
53
|
+
|
53
54
|
alias_method :__type, :parse_class
|
54
55
|
|
55
56
|
# The initializer can create a GeoPoint with a hash, array or values.
|
@@ -77,7 +78,6 @@ module Parse
|
|
77
78
|
|
78
79
|
# @!visibility private
|
79
80
|
def _validate_point
|
80
|
-
|
81
81
|
unless @latitude.nil? || @latitude.between?(LAT_MIN, LAT_MAX)
|
82
82
|
warn "[Parse::GeoPoint] Latitude (#{@latitude}) is not between #{LAT_MIN}, #{LAT_MAX}!"
|
83
83
|
warn "Attempting to use GeoPoint’s with latitudes outside these ranges will raise an exception in a future release."
|
@@ -87,7 +87,6 @@ module Parse
|
|
87
87
|
warn "[Parse::GeoPoint] Longitude (#{@longitude}) is not between #{LNG_MIN}, #{LNG_MAX}!"
|
88
88
|
warn "Attempting to use GeoPoint’s with longitude outside these ranges will raise an exception in a future release."
|
89
89
|
end
|
90
|
-
|
91
90
|
end
|
92
91
|
|
93
92
|
# @return [Hash] attributes for a Parse GeoPoint.
|
@@ -99,7 +98,7 @@ module Parse
|
|
99
98
|
# @return [Array] containing [lat,lng,miles]
|
100
99
|
def max_miles(m)
|
101
100
|
m = 0 if m.nil?
|
102
|
-
[@latitude
|
101
|
+
[@latitude, @longitude, m]
|
103
102
|
end
|
104
103
|
|
105
104
|
def latitude=(l)
|
@@ -118,7 +117,7 @@ module Parse
|
|
118
117
|
if h.is_a?(Hash)
|
119
118
|
h = h.symbolize_keys
|
120
119
|
@latitude = h[:latitude].to_f || h[:lat].to_f || @latitude
|
121
|
-
@longitude = h[:longitude].to_f || h[:lng].to_f ||
|
120
|
+
@longitude = h[:longitude].to_f || h[:lng].to_f || @longitude
|
122
121
|
elsif h.is_a?(Array) && h.count == 2
|
123
122
|
@latitude = h.first.to_f
|
124
123
|
@longitude = h.last.to_f
|
@@ -142,7 +141,7 @@ module Parse
|
|
142
141
|
# Returns a tuple containing latitude and longitude
|
143
142
|
# @return [Array]
|
144
143
|
def to_a
|
145
|
-
[@latitude
|
144
|
+
[@latitude, @longitude]
|
146
145
|
end
|
147
146
|
|
148
147
|
# @!visibility private
|
@@ -161,7 +160,7 @@ module Parse
|
|
161
160
|
# is longitude instead of a GeoPoint.
|
162
161
|
# @return [Float] number of miles between geopoints.
|
163
162
|
# @see #distance_in_km
|
164
|
-
def distance_in_miles(geopoint,lng = nil)
|
163
|
+
def distance_in_miles(geopoint, lng = nil)
|
165
164
|
distance_in_km(geopoint, lng) * 0.621371
|
166
165
|
end
|
167
166
|
|
@@ -175,12 +174,12 @@ module Parse
|
|
175
174
|
# @param lng [Float] Longitude assuming that the first parameter is a latitude instead of a GeoPoint.
|
176
175
|
# @return [Float] number of miles between geopoints.
|
177
176
|
# @see #distance_in_miles
|
178
|
-
def distance_in_km(geopoint,lng = nil)
|
177
|
+
def distance_in_km(geopoint, lng = nil)
|
179
178
|
unless geopoint.is_a?(Parse::GeoPoint)
|
180
179
|
geopoint = Parse::GeoPoint.new(geopoint, lng)
|
181
180
|
end
|
182
181
|
|
183
|
-
dtor = Math::PI/180
|
182
|
+
dtor = Math::PI / 180
|
184
183
|
r = 6378.14
|
185
184
|
r_lat1 = self.latitude * dtor
|
186
185
|
r_lng1 = self.longitude * dtor
|
@@ -190,13 +189,10 @@ module Parse
|
|
190
189
|
delta_lat = r_lat1 - r_lat2
|
191
190
|
delta_lng = r_lng1 - r_lng2
|
192
191
|
|
193
|
-
a = (Math::sin(delta_lat/2.0) ** 2).to_f + (Math::cos(r_lat1) * Math::cos(r_lat2) * (
|
194
|
-
c = 2.0 * Math::atan2(Math::sqrt(a), Math::sqrt(1.0-a))
|
192
|
+
a = (Math::sin(delta_lat / 2.0) ** 2).to_f + (Math::cos(r_lat1) * Math::cos(r_lat2) * (Math::sin(delta_lng / 2.0) ** 2))
|
193
|
+
c = 2.0 * Math::atan2(Math::sqrt(a), Math::sqrt(1.0 - a))
|
195
194
|
d = r * c
|
196
195
|
d
|
197
196
|
end
|
198
|
-
|
199
|
-
|
200
197
|
end
|
201
|
-
|
202
198
|
end
|
data/lib/parse/model/model.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require_relative
|
4
|
+
require "active_model"
|
5
|
+
require "active_support"
|
6
|
+
require "active_support/inflector"
|
7
|
+
require "active_support/core_ext/object"
|
8
|
+
require "active_model_serializers"
|
9
|
+
require_relative "../client"
|
10
10
|
|
11
11
|
module Parse
|
12
12
|
# Find a corresponding Parse::Object subclass for this string or symbol
|
@@ -21,61 +21,59 @@ module Parse
|
|
21
21
|
# serialization, dirty tracking, callbacks, etc.
|
22
22
|
# @see ActiveModel
|
23
23
|
class Model
|
24
|
-
|
25
24
|
include Client::Connectable # allows easy default Parse::Client access
|
26
25
|
include ::ActiveModel::Model
|
27
26
|
include ::ActiveModel::Serializers::JSON # support for JSON Serializers
|
28
27
|
include ::ActiveModel::Dirty # adds dirty tracking support
|
29
28
|
include ::ActiveModel::Conversion
|
30
|
-
extend
|
31
|
-
extend
|
29
|
+
extend ::ActiveModel::Callbacks # callback support on save, update, delete, etc.
|
30
|
+
extend ::ActiveModel::Naming # provides the methods for getting class names from Model classes
|
32
31
|
|
33
32
|
# The name of the field in a hash that contains information about the type
|
34
33
|
# of data the hash represents.
|
35
|
-
TYPE_FIELD =
|
34
|
+
TYPE_FIELD = "__type".freeze
|
36
35
|
|
37
36
|
# The objectId field in Parse Objects.
|
38
|
-
OBJECT_ID
|
37
|
+
OBJECT_ID = "objectId".freeze
|
39
38
|
# @see OBJECT_ID
|
40
39
|
ID = "id".freeze
|
41
40
|
|
42
41
|
# The key field for getting class information.
|
43
|
-
KEY_CLASS_NAME
|
42
|
+
KEY_CLASS_NAME = "className".freeze
|
44
43
|
# @deprecated Use OBJECT_ID instead.
|
45
|
-
KEY_OBJECT_ID
|
44
|
+
KEY_OBJECT_ID = "objectId".freeze
|
46
45
|
# The key field for getting the created at date of an object hash.
|
47
|
-
KEY_CREATED_AT
|
46
|
+
KEY_CREATED_AT = "createdAt"
|
48
47
|
# The key field for getting the updated at date of an object hash.
|
49
|
-
KEY_UPDATED_AT
|
48
|
+
KEY_UPDATED_AT = "updatedAt"
|
50
49
|
# The collection for Users in Parse. Used by Parse::User.
|
51
|
-
CLASS_USER
|
50
|
+
CLASS_USER = "_User"
|
52
51
|
# The collection for Installations in Parse. Used by Parse::Installation.
|
53
|
-
CLASS_INSTALLATION =
|
52
|
+
CLASS_INSTALLATION = "_Installation"
|
54
53
|
# The collection for revocable Sessions in Parse. Used by Parse::Session.
|
55
|
-
CLASS_SESSION =
|
54
|
+
CLASS_SESSION = "_Session"
|
56
55
|
# The collection for Roles in Parse. Used by Parse::Role.
|
57
|
-
CLASS_ROLE =
|
56
|
+
CLASS_ROLE = "_Role"
|
58
57
|
# The collection for to store Products (in-App purchases) in Parse. Used by Parse::Product.
|
59
|
-
CLASS_PRODUCT =
|
58
|
+
CLASS_PRODUCT = "_Product"
|
60
59
|
# The type label for hashes containing file data. Used by Parse::File.
|
61
|
-
TYPE_FILE =
|
60
|
+
TYPE_FILE = "File"
|
62
61
|
# The type label for hashes containing geopoints. Used by Parse::GeoPoint.
|
63
|
-
TYPE_GEOPOINT =
|
62
|
+
TYPE_GEOPOINT = "GeoPoint"
|
64
63
|
# The type label for hashes containing a Parse object. Used by Parse::Object and subclasses.
|
65
|
-
TYPE_OBJECT =
|
64
|
+
TYPE_OBJECT = "Object"
|
66
65
|
# The type label for hashes containing a Parse date object. Used by Parse::Date.
|
67
|
-
TYPE_DATE =
|
66
|
+
TYPE_DATE = "Date"
|
68
67
|
# The type label for hashes containing 'byte' data. Used by Parse::Bytes.
|
69
|
-
TYPE_BYTES =
|
68
|
+
TYPE_BYTES = "Bytes"
|
70
69
|
# The type label for hashes containing ACL data. Used by Parse::ACL
|
71
|
-
TYPE_ACL =
|
70
|
+
TYPE_ACL = "ACL"
|
72
71
|
# The type label for hashes storing numeric data.
|
73
|
-
TYPE_NUMBER =
|
72
|
+
TYPE_NUMBER = "Number"
|
74
73
|
# The type label for hashes containing a Parse pointer.
|
75
|
-
TYPE_POINTER =
|
74
|
+
TYPE_POINTER = "Pointer"
|
76
75
|
# The type label for hashes representing relational data.
|
77
|
-
TYPE_RELATION =
|
78
|
-
|
76
|
+
TYPE_RELATION = "Relation"
|
79
77
|
|
80
78
|
# To support being able to have different ruby class names from the 'table'
|
81
79
|
# names used in Parse, we will need to have a dynamic lookup system where
|
@@ -115,7 +113,6 @@ module Parse
|
|
115
113
|
def raise_on_save_failure=(bool)
|
116
114
|
@global_raise_on_save_failure = bool
|
117
115
|
end
|
118
|
-
|
119
116
|
end
|
120
117
|
|
121
118
|
# Find a Parse::Model subclass matching this type or Pares collection name.
|
@@ -149,11 +146,8 @@ module Parse
|
|
149
146
|
@@model_cache[str] ||= Parse::Object.descendants.find do |f|
|
150
147
|
f.parse_class == str || f.parse_class == "_#{str}"
|
151
148
|
end
|
152
|
-
|
153
149
|
end
|
154
|
-
|
155
150
|
end
|
156
|
-
|
157
151
|
end
|
158
152
|
|
159
153
|
# Add extensions to the String class.
|
@@ -172,9 +166,9 @@ class String
|
|
172
166
|
# @return [String]
|
173
167
|
# @see Parse::Query.field_formatter
|
174
168
|
def columnize
|
175
|
-
|
176
|
-
|
177
|
-
|
169
|
+
return Parse::Model::OBJECT_ID if self == Parse::Model::ID
|
170
|
+
u = "_".freeze
|
171
|
+
(first == u ? sub(u, "") : self).camelize(:lower)
|
178
172
|
end
|
179
173
|
|
180
174
|
# Convert a string to a Parse class name. This method tries to find a
|
data/lib/parse/model/object.rb
CHANGED
@@ -1,42 +1,41 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
13
|
-
|
14
|
-
require_relative
|
15
|
-
require_relative
|
16
|
-
require_relative
|
17
|
-
require_relative
|
18
|
-
require_relative
|
19
|
-
require_relative
|
20
|
-
require_relative
|
21
|
-
require_relative
|
22
|
-
require_relative
|
23
|
-
require_relative
|
24
|
-
require_relative
|
25
|
-
require_relative
|
26
|
-
require_relative
|
27
|
-
require_relative
|
28
|
-
require_relative
|
29
|
-
require_relative
|
30
|
-
require_relative
|
31
|
-
require_relative
|
32
|
-
require_relative
|
33
|
-
require_relative
|
34
|
-
|
4
|
+
require "active_model"
|
5
|
+
require "active_support"
|
6
|
+
require "active_support/inflector"
|
7
|
+
require "active_support/core_ext"
|
8
|
+
require "active_support/core_ext/object"
|
9
|
+
require "active_support/core_ext/string"
|
10
|
+
require "active_model_serializers"
|
11
|
+
require "time"
|
12
|
+
require "open-uri"
|
13
|
+
|
14
|
+
require_relative "../client"
|
15
|
+
require_relative "model"
|
16
|
+
require_relative "pointer"
|
17
|
+
require_relative "geopoint"
|
18
|
+
require_relative "file"
|
19
|
+
require_relative "bytes"
|
20
|
+
require_relative "date"
|
21
|
+
require_relative "time_zone"
|
22
|
+
require_relative "acl"
|
23
|
+
require_relative "push"
|
24
|
+
require_relative "core/actions"
|
25
|
+
require_relative "core/fetching"
|
26
|
+
require_relative "core/querying"
|
27
|
+
require_relative "core/schema"
|
28
|
+
require_relative "core/properties"
|
29
|
+
require_relative "core/errors"
|
30
|
+
require_relative "core/builder"
|
31
|
+
require_relative "associations/has_one"
|
32
|
+
require_relative "associations/belongs_to"
|
33
|
+
require_relative "associations/has_many"
|
35
34
|
|
36
35
|
module Parse
|
37
36
|
# @return [Array] an array of registered Parse::Object subclasses.
|
38
37
|
def self.registered_classes
|
39
|
-
|
38
|
+
Parse::Object.descendants.map(&:parse_class).uniq
|
40
39
|
end
|
41
40
|
|
42
41
|
# @return [Array<Hash>] the list of all schemas for this application.
|
@@ -65,7 +64,7 @@ module Parse
|
|
65
64
|
# Alias shorter names of core Parse class names.
|
66
65
|
# Ex, alias Parse::User to User, Parse::Installation to Installation, etc.
|
67
66
|
def self.use_shortnames!
|
68
|
-
require_relative
|
67
|
+
require_relative "shortnames"
|
69
68
|
end
|
70
69
|
|
71
70
|
# This is the core class for all app specific Parse table subclasses. This class
|
@@ -139,7 +138,7 @@ module Parse
|
|
139
138
|
BASE_OBJECT_CLASS = "Parse::Object".freeze
|
140
139
|
|
141
140
|
# @return [Model::TYPE_OBJECT]
|
142
|
-
def __type; Parse::Model::TYPE_OBJECT; end
|
141
|
+
def __type; Parse::Model::TYPE_OBJECT; end
|
143
142
|
|
144
143
|
# Default ActiveModel::Callbacks
|
145
144
|
# @!group Callbacks
|
@@ -183,13 +182,8 @@ module Parse
|
|
183
182
|
# the remote Parse table is named 'Artist'. You may override this behavior by utilizing the `parse_class(<className>)` method
|
184
183
|
# to set it to something different.
|
185
184
|
class << self
|
186
|
-
|
187
|
-
attr_accessor :disable_serialized_string_date, :parse_class
|
185
|
+
attr_accessor :parse_class
|
188
186
|
attr_reader :default_acls
|
189
|
-
# @!attribute disable_serialized_string_date
|
190
|
-
# Disables returning a serialized string date properties when encoding to JSON.
|
191
|
-
# This affects created_at and updated_at fields in order to be backwards compatible with old SDKs.
|
192
|
-
# @return [Boolean] the disabled status of whether string dates should be serialized.
|
193
187
|
|
194
188
|
# The class method to override the implicitly assumed Parse collection name
|
195
189
|
# in your Parse database. The default Parse collection name is the singular form
|
@@ -257,7 +251,6 @@ module Parse
|
|
257
251
|
def acl(acls, owner: nil)
|
258
252
|
raise "[#{self}.acl DEPRECATED] - Use `#{self}.default_acl` instead."
|
259
253
|
end
|
260
|
-
|
261
254
|
end # << self
|
262
255
|
|
263
256
|
# @return [String] the Parse class for this object.
|
@@ -265,6 +258,7 @@ module Parse
|
|
265
258
|
def parse_class
|
266
259
|
self.class.parse_class
|
267
260
|
end
|
261
|
+
|
268
262
|
alias_method :className, :parse_class
|
269
263
|
|
270
264
|
# @return [Hash] the schema structure for this Parse collection from the server.
|
@@ -351,7 +345,7 @@ module Parse
|
|
351
345
|
# @param opts [Hash] a set of options to send to fetch!
|
352
346
|
# @see Fetching#fetch!
|
353
347
|
def reload!(opts = {})
|
354
|
-
|
348
|
+
# get the values from the persistence layer
|
355
349
|
fetch!(opts)
|
356
350
|
clear_changes!
|
357
351
|
end
|
@@ -440,7 +434,7 @@ module Parse
|
|
440
434
|
# @return [String] a pretty-formatted JSON string
|
441
435
|
# @see JSON.pretty_generate
|
442
436
|
def pretty
|
443
|
-
JSON.pretty_generate(
|
437
|
+
JSON.pretty_generate(as_json)
|
444
438
|
end
|
445
439
|
|
446
440
|
# clear all change and dirty tracking information.
|
@@ -487,10 +481,10 @@ module Parse
|
|
487
481
|
o = Parse::Pointer.new className, (json[Parse::Model::OBJECT_ID] || json[:objectId])
|
488
482
|
end
|
489
483
|
return o
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
484
|
+
# rescue NameError => e
|
485
|
+
# puts "Parse::Object.build constant class error: #{e}"
|
486
|
+
# rescue Exception => e
|
487
|
+
# puts "Parse::Object.build error: #{e}"
|
494
488
|
end
|
495
489
|
|
496
490
|
# @!attribute id
|
@@ -509,20 +503,6 @@ module Parse
|
|
509
503
|
# @return [ACL] the access control list (permissions) object for this record.
|
510
504
|
property :acl, :acl, field: :ACL
|
511
505
|
|
512
|
-
# Alias to {created_at}
|
513
|
-
# @return (see #created_at)
|
514
|
-
def createdAt
|
515
|
-
return @created_at if Parse::Object.disable_serialized_string_date.present?
|
516
|
-
@created_at.to_time.utc.iso8601(3) if @created_at.present?
|
517
|
-
end
|
518
|
-
|
519
|
-
# Alias to {updated_at}
|
520
|
-
# @return (see #updated_at)
|
521
|
-
def updatedAt
|
522
|
-
return @updated_at if Parse::Object.disable_serialized_string_date.present?
|
523
|
-
@updated_at.to_time.utc.iso8601(3) if @updated_at.present?
|
524
|
-
end
|
525
|
-
|
526
506
|
# Access the value for a defined property through hash accessor. This method
|
527
507
|
# returns nil if the key is not one of the defined properties for this Parse::Object
|
528
508
|
# subclass.
|
@@ -539,14 +519,23 @@ module Parse
|
|
539
519
|
# @param key (see Parse::Object#[])
|
540
520
|
# @param value [Object] the value to set this property.
|
541
521
|
# @return [Object] the value passed in.
|
542
|
-
def []=(key,value)
|
522
|
+
def []=(key, value)
|
543
523
|
return unless self.class.fields[key.to_sym].present?
|
544
|
-
send("#{key}=",value)
|
524
|
+
send("#{key}=", value)
|
545
525
|
end
|
546
|
-
|
547
526
|
end
|
527
|
+
end
|
548
528
|
|
529
|
+
class Hash
|
549
530
|
|
531
|
+
# Turns a Parse formatted JSON hash into a Parse-Stack class object, if one is found.
|
532
|
+
# This is equivalent to calling `Parse::Object.build` on the hash object itself, but allows
|
533
|
+
# for doing this in loops, such as `map` when using symbol to proc. However, you can also use
|
534
|
+
# the Array extension `Array#parse_objects` for doing that more safely.
|
535
|
+
# @return [Parse::Object] A Parse::Object subclass represented the built class.
|
536
|
+
def parse_object
|
537
|
+
Parse::Object.build(self)
|
538
|
+
end
|
550
539
|
end
|
551
540
|
|
552
541
|
class Array
|
@@ -571,12 +560,11 @@ class Array
|
|
571
560
|
def parse_ids
|
572
561
|
parse_objects.map(&:id)
|
573
562
|
end
|
574
|
-
|
575
563
|
end
|
576
564
|
|
577
565
|
# Load all the core classes.
|
578
|
-
require_relative
|
579
|
-
require_relative
|
580
|
-
require_relative
|
581
|
-
require_relative
|
582
|
-
require_relative
|
566
|
+
require_relative "classes/installation"
|
567
|
+
require_relative "classes/product"
|
568
|
+
require_relative "classes/role"
|
569
|
+
require_relative "classes/session"
|
570
|
+
require_relative "classes/user"
|