parse-stack 1.7.3 → 1.7.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +4 -2
- data/Changes.md +23 -4
- data/Gemfile.lock +25 -25
- data/README.md +17 -16
- data/lib/parse/api/objects.rb +2 -2
- data/lib/parse/model/associations/belongs_to.rb +5 -3
- data/lib/parse/model/associations/collection_proxy.rb +12 -0
- data/lib/parse/model/associations/has_many.rb +4 -2
- data/lib/parse/model/associations/has_one.rb +1 -1
- data/lib/parse/model/associations/pointer_collection_proxy.rb +0 -5
- data/lib/parse/model/classes/user.rb +1 -1
- data/lib/parse/model/core/builder.rb +1 -1
- data/lib/parse/model/core/properties.rb +2 -2
- data/lib/parse/model/date.rb +1 -7
- data/lib/parse/model/object.rb +13 -19
- data/lib/parse/stack.rb +6 -1
- data/lib/parse/stack/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: adfaf3f682758219d766199934910e0f885bbe3770d5aba4ceb73e575b29a236
|
4
|
+
data.tar.gz: 0ae3f2fba6aa06d1ecc9eb01fd1110066813eed944ec610b1b76c31e55a4a7da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 182fba0ec6563b3c3946d5fdb10d6ad66d9a6777a1c8df8e048935f786c2be1c08e1291b6f586e7cb81b304826cf30581fd5aa1a05be060033c4a21279551264
|
7
|
+
data.tar.gz: 5184b7124197babce5fd543c04096b4ca1284be8be44b0f1df2167b8a8ba813709a11d08007c73194f6c7ca321d97056ac9fd41fdbe7d8da6bf27de825cd17af
|
data/.travis.yml
CHANGED
data/Changes.md
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
## Parse-Stack Changelog
|
2
2
|
|
3
|
+
### 1.7.4
|
4
|
+
- NEW: Added `parse_object` extension to Hash classes to more easily call
|
5
|
+
Parse::Object.build in `map` loops with symbol to proc.
|
6
|
+
- CHANGED: Renamed `hyperdrive_config!` to `Parse::Hyperdrive.config!`
|
7
|
+
- REMOVED: The used of non-JSON dates has been removed for `createdAt` and `updatedAt`
|
8
|
+
fields as all Parse SDKs now support the new JSON format. `Parse.disable_serialized_string_date`
|
9
|
+
has also been removed so that `created_at` and `updated_at` return the same value
|
10
|
+
as `createdAt` and `updatedAt` respectively.
|
11
|
+
- FIXED: Builder properly auto generates Parse Relation associations using `through: :relation`.
|
12
|
+
- REMOVED: Defining `has_many` or `belongs_to` associations more than once will no longer result
|
13
|
+
in an `ArgumentError` (they are now warnings). This will allow you to define associations for classes before calling `auto_generate_models!`
|
14
|
+
- CHANGED: Parse::CollectionProxy now supports `parse_objects` and `parse_pointers` for compatibility with the
|
15
|
+
sibling `Array` methods. Having an Parse-JSON Hash array or a Parse::CollectionProxy which contains a series
|
16
|
+
of Parse hashes can now be easily converted to an array of Parse objects with these methods.
|
17
|
+
- FIXED: Correctly discards ACL changes on User model saves.
|
18
|
+
- FIXED: Fixes issues with double '/' in update URI paths.
|
19
|
+
|
3
20
|
### 1.7.3
|
4
21
|
- CHANGED: Moved to using preferred ENV variable names based on parse-server cli.
|
5
22
|
- CHANGED: Default url is now http://localhost:1337/parse
|
@@ -8,7 +25,7 @@
|
|
8
25
|
### 1.7.2
|
9
26
|
- NEW: `Parse::Model.autosave_on_create` has been removed in favor of `first_or_create!`.
|
10
27
|
- NEW: Webhook Triggers and Functions now have a `wlog` method, similar to `puts`, but allows easier tracing of
|
11
|
-
single requests in a multi-request threaded environment. (See Parse::Webhooks::Payload)
|
28
|
+
single requests in a multi-request threaded environment. (See Parse::Webhooks::Payload)
|
12
29
|
- NEW: `:id` constraints also safely supports pointers by skipping class matching.
|
13
30
|
- NEW: Support for `add_unique` and the set union operator `|` in collection proxies.
|
14
31
|
- NEW: Support for `uniq` and `uniq!` in collection proxies.
|
@@ -22,10 +39,12 @@ single requests in a multi-request threaded environment. (See Parse::Webhooks::P
|
|
22
39
|
- NEW: Added `Parse::Query#append` as alias to `Parse::Query#conditions`
|
23
40
|
- CHANGED: `save_all` now returns true if there were no errors.
|
24
41
|
- FIXED: first_or_create will now apply dirty tracking to newly created fields.
|
25
|
-
- FIXED: Properties of :array type will always return a Parse::CollectionProxy if
|
42
|
+
- FIXED: Properties of :array type will always return a Parse::CollectionProxy if
|
43
|
+
their internal value is nil. The object will not be marked dirty until something is added to the array.
|
26
44
|
- FIXED: Encoding a Parse::Object into JSON will remove any values that are `nil`
|
27
|
-
which were not explicitly changed to that value.
|
28
|
-
- [PR#39](https://github.com/modernistik/parse-stack/pull/39): Allow Moneta::Expires
|
45
|
+
which were not explicitly changed to that value.
|
46
|
+
- [PR#39](https://github.com/modernistik/parse-stack/pull/39): Allow Moneta::Expires
|
47
|
+
as cache object to allow for non-native expiring caches by [GrahamW](https://github.com/GrahamW)
|
29
48
|
|
30
49
|
|
31
50
|
### 1.7.1
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
parse-stack (1.7.
|
4
|
+
parse-stack (1.7.4)
|
5
5
|
active_model_serializers (>= 0.9, < 1)
|
6
6
|
activemodel (>= 4.2.1, < 6)
|
7
7
|
activesupport (>= 4.2.1, < 6)
|
@@ -14,15 +14,15 @@ PATH
|
|
14
14
|
GEM
|
15
15
|
remote: https://rubygems.org/
|
16
16
|
specs:
|
17
|
-
actionpack (5.
|
18
|
-
actionview (= 5.
|
19
|
-
activesupport (= 5.
|
17
|
+
actionpack (5.2.0)
|
18
|
+
actionview (= 5.2.0)
|
19
|
+
activesupport (= 5.2.0)
|
20
20
|
rack (~> 2.0)
|
21
21
|
rack-test (>= 0.6.3)
|
22
22
|
rails-dom-testing (~> 2.0)
|
23
23
|
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
24
|
-
actionview (5.
|
25
|
-
activesupport (= 5.
|
24
|
+
actionview (5.2.0)
|
25
|
+
activesupport (= 5.2.0)
|
26
26
|
builder (~> 3.1)
|
27
27
|
erubi (~> 1.4)
|
28
28
|
rails-dom-testing (~> 2.0)
|
@@ -32,35 +32,35 @@ GEM
|
|
32
32
|
activemodel (>= 4.1, < 6)
|
33
33
|
case_transform (>= 0.2)
|
34
34
|
jsonapi-renderer (>= 0.1.1.beta1, < 0.3)
|
35
|
-
activemodel (5.
|
36
|
-
activesupport (= 5.
|
37
|
-
activesupport (5.
|
35
|
+
activemodel (5.2.0)
|
36
|
+
activesupport (= 5.2.0)
|
37
|
+
activesupport (5.2.0)
|
38
38
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
39
|
-
i18n (
|
39
|
+
i18n (>= 0.7, < 2)
|
40
40
|
minitest (~> 5.1)
|
41
41
|
tzinfo (~> 1.1)
|
42
42
|
binding_of_caller (0.8.0)
|
43
43
|
debug_inspector (>= 0.0.1)
|
44
44
|
builder (3.2.3)
|
45
|
-
byebug (10.0.
|
45
|
+
byebug (10.0.2)
|
46
46
|
case_transform (0.2)
|
47
47
|
activesupport
|
48
48
|
coderay (1.1.2)
|
49
49
|
concurrent-ruby (1.0.5)
|
50
|
-
crass (1.0.
|
50
|
+
crass (1.0.4)
|
51
51
|
daemons (1.2.6)
|
52
52
|
debug_inspector (0.0.3)
|
53
|
-
dotenv (2.
|
54
|
-
erubi (1.7.
|
55
|
-
eventmachine (1.2.
|
56
|
-
faraday (0.
|
53
|
+
dotenv (2.4.0)
|
54
|
+
erubi (1.7.1)
|
55
|
+
eventmachine (1.2.7)
|
56
|
+
faraday (0.15.2)
|
57
57
|
multipart-post (>= 1.2, < 3)
|
58
58
|
faraday_middleware (0.12.2)
|
59
59
|
faraday (>= 0.7.4, < 1.0)
|
60
|
-
i18n (0.
|
60
|
+
i18n (1.0.1)
|
61
61
|
concurrent-ruby (~> 1.0)
|
62
62
|
jsonapi-renderer (0.2.0)
|
63
|
-
loofah (2.2.
|
63
|
+
loofah (2.2.2)
|
64
64
|
crass (~> 1.0.2)
|
65
65
|
nokogiri (>= 1.5.9)
|
66
66
|
method_source (0.8.2)
|
@@ -80,15 +80,15 @@ GEM
|
|
80
80
|
pry-stack_explorer (0.4.9.2)
|
81
81
|
binding_of_caller (>= 0.7)
|
82
82
|
pry (>= 0.9.11)
|
83
|
-
rack (2.0.
|
84
|
-
rack-test (0.
|
83
|
+
rack (2.0.5)
|
84
|
+
rack-test (1.0.0)
|
85
85
|
rack (>= 1.0, < 3)
|
86
86
|
rails-dom-testing (2.0.3)
|
87
87
|
activesupport (>= 4.2.0)
|
88
88
|
nokogiri (>= 1.6)
|
89
|
-
rails-html-sanitizer (1.0.
|
90
|
-
loofah (~> 2.
|
91
|
-
rake (12.3.
|
89
|
+
rails-html-sanitizer (1.0.4)
|
90
|
+
loofah (~> 2.2, >= 2.2.2)
|
91
|
+
rake (12.3.1)
|
92
92
|
redcarpet (3.4.0)
|
93
93
|
redis (4.0.1)
|
94
94
|
slop (3.6.0)
|
@@ -99,7 +99,7 @@ GEM
|
|
99
99
|
thread_safe (0.3.6)
|
100
100
|
tzinfo (1.2.5)
|
101
101
|
thread_safe (~> 0.1)
|
102
|
-
yard (0.9.
|
102
|
+
yard (0.9.13)
|
103
103
|
|
104
104
|
PLATFORMS
|
105
105
|
ruby
|
@@ -119,4 +119,4 @@ DEPENDENCIES
|
|
119
119
|
yard (>= 0.9.11)
|
120
120
|
|
121
121
|
BUNDLED WITH
|
122
|
-
1.16.
|
122
|
+
1.16.2
|
data/README.md
CHANGED
@@ -6,19 +6,18 @@
|
|
6
6
|
|
7
7
|
Below is a [quick start guide](https://github.com/modernistik/parse-stack#overview), but you can also check out the full *[API Reference](https://www.modernistik.com/gems/parse-stack/index.html)* for more detailed information about our Parse Server SDK.
|
8
8
|
|
9
|
-
#### Tutorial Videos
|
10
|
-
1. Getting Started: https://youtu.be/zoYSGmciDlQ
|
11
|
-
2. Custom Classes and Relations: https://youtu.be/tfSesotfU7w
|
12
|
-
3. Working with Existing Schemas: https://youtu.be/EJGPT7YWyXA
|
13
|
-
|
14
9
|
### Code Status
|
15
10
|
[![Gem Version](https://img.shields.io/gem/v/parse-stack.svg)](https://github.com/modernistik/parse-stack)
|
16
11
|
[![Downloads](https://img.shields.io/gem/dt/parse-stack.svg)](https://rubygems.org/gems/parse-stack)
|
17
12
|
[![Build Status](https://travis-ci.org/modernistik/parse-stack.svg?branch=master)](https://travis-ci.org/modernistik/parse-stack)
|
18
13
|
[![API Reference](http://img.shields.io/badge/api-docs-blue.svg)](https://www.modernistik.com/gems/parse-stack/index.html)
|
19
14
|
|
20
|
-
|
21
|
-
|
15
|
+
#### Tutorial Videos
|
16
|
+
1. Getting Started: https://youtu.be/zoYSGmciDlQ
|
17
|
+
2. Custom Classes and Relations: https://youtu.be/tfSesotfU7w
|
18
|
+
3. Working with Existing Schemas: https://youtu.be/EJGPT7YWyXA
|
19
|
+
|
20
|
+
Any other questions, please post them on StackOverflow with the proper parse-stack / parse-server / ruby tags.
|
22
21
|
|
23
22
|
## Installation
|
24
23
|
|
@@ -350,7 +349,7 @@ A caching adapter of type `Moneta::Transformer`. Caching queries and object fetc
|
|
350
349
|
Parse.setup(cache: store, expires: 10, ...)
|
351
350
|
```
|
352
351
|
|
353
|
-
As a shortcut, if you are planning on using REDIS and have configured the use of `redis` in your `Gemfile`, you can just pass the
|
352
|
+
As a shortcut, if you are planning on using REDIS and have configured the use of `redis` in your `Gemfile`, you can just pass the REDIS connection string directly to the cache option.
|
354
353
|
|
355
354
|
```ruby
|
356
355
|
Parse.setup(cache: 'redis://localhost:6379', ...)
|
@@ -363,7 +362,7 @@ Sets the default cache expiration time (in seconds) for successful non-empty `GE
|
|
363
362
|
You may pass a hash of options that will be passed to the `Faraday` constructor.
|
364
363
|
|
365
364
|
## Working With Existing Schemas
|
366
|
-
If you already have a Parse application with defined schemas and collections, you can have Parse-Stack automatically generate the ruby Parse::Object subclasses instead of writing them on your own. Through this process, the framework will download all the defined schemas of all your collections, and infer the properties and associations defined. While this method is useful for getting started with the framework with an existing app, we highly recommend
|
365
|
+
If you already have a Parse application with defined schemas and collections, you can have Parse-Stack automatically generate the ruby Parse::Object subclasses instead of writing them on your own. Through this process, the framework will download all the defined schemas of all your collections, and infer the properties and associations defined. While this method is useful for getting started with the framework with an existing app, we highly recommend defining your own models. This would allow you to customize and utilize all the features available in Parse Stack.
|
367
366
|
|
368
367
|
```ruby
|
369
368
|
# after you have called Parse.setup
|
@@ -516,8 +515,6 @@ This class manages dates in the special JSON format it requires for properties o
|
|
516
515
|
song.save # ok
|
517
516
|
```
|
518
517
|
|
519
|
-
One important note with dates, is that `created_at` and `updated_at` columns do not follow this convention all the time. Depending on the Cloud Code SDK, they can be the Parse ISO hash date format or the `iso8601` string format. By default, these are serialized as `iso8601` when sent as responses to Parse for backwards compatibility with some clients. To use the Parse ISO hash format for these fields instead, set `Parse::Object.disable_serialized_string_date = true`.
|
520
|
-
|
521
518
|
### [Parse::GeoPoint](https://www.modernistik.com/gems/parse-stack/Parse/GeoPoint.html)
|
522
519
|
This class manages the GeoPoint data type that Parse provides to support geo-queries. To define a GeoPoint property, use the `:geopoint` data type. Please note that latitudes should not be between -90.0 and 90.0, and longitudes should be between -180.0 and 180.0.
|
523
520
|
|
@@ -627,7 +624,7 @@ All `Parse::Object` subclasses have an `acl` property by default. With this prop
|
|
627
624
|
|
628
625
|
artist.save
|
629
626
|
```
|
630
|
-
You may also set default ACLs for newly created
|
627
|
+
You may also set default ACLs for newly created instances of your subclasses using `set_default_acl`:
|
631
628
|
|
632
629
|
```ruby
|
633
630
|
class AdminData < Parse::Object
|
@@ -864,7 +861,7 @@ end
|
|
864
861
|
|
865
862
|
After properties are defined, you can use appropriate getter and setter methods to modify the values. As properties become modified, the model will keep track of the changes using the [dirty tracking feature of ActiveModel](http://api.rubyonrails.org/classes/ActiveModel/Dirty.html). If an attribute is modified in-place then make use of **[attribute_name]_will_change!** to mark that the attribute is changing. Otherwise ActiveModel can't track changes to in-place attributes.
|
866
863
|
|
867
|
-
To support dirty tracking on properties of data type of `:array`, we utilize a proxy class called `Parse::CollectionProxy`. This class has special functionality which allows lazy loading of content as well and keeping track of the changes that are made. While you are able to access the internal array on the collection through the `#collection` method, it is important not to make in-place edits to the object. You should use the preferred methods of `#add` and `#remove` to modify the contents of the collection. When `#save` is called on the object, the changes will be
|
864
|
+
To support dirty tracking on properties of data type of `:array`, we utilize a proxy class called `Parse::CollectionProxy`. This class has special functionality which allows lazy loading of content as well and keeping track of the changes that are made. While you are able to access the internal array on the collection through the `#collection` method, it is important not to make in-place edits to the object. You should use the preferred methods of `#add` and `#remove` to modify the contents of the collection. When `#save` is called on the object, the changes will be committed to Parse.
|
868
865
|
|
869
866
|
```ruby
|
870
867
|
post = Post.first
|
@@ -1525,7 +1522,7 @@ For the cases when you want to modify the items in this association without havi
|
|
1525
1522
|
artist.songs.add! song # Add operation
|
1526
1523
|
artist.songs.add_unique! other_song # AddUnique operation
|
1527
1524
|
artist.songs.remove! another_song # Remove operation
|
1528
|
-
artist.save #
|
1525
|
+
artist.save # no-op. (no operations were sent directly to Parse)
|
1529
1526
|
|
1530
1527
|
artist.songs.destroy! # Delete operation of all Songs
|
1531
1528
|
```
|
@@ -1648,7 +1645,7 @@ However, Parse-Stack performs automatic fetching of associations when the associ
|
|
1648
1645
|
song.artist.name
|
1649
1646
|
|
1650
1647
|
# You can manually do the same with `fetch` and `fetch!`
|
1651
|
-
song.artist.fetch # considered "fetch if needed".
|
1648
|
+
song.artist.fetch # considered "fetch if needed". No-op if not needed.
|
1652
1649
|
song.artist.fetch! # force fetch regardless of state.
|
1653
1650
|
```
|
1654
1651
|
|
@@ -2613,9 +2610,13 @@ end
|
|
2613
2610
|
|
2614
2611
|
```
|
2615
2612
|
|
2613
|
+
## Hire Us
|
2614
|
+
|
2615
|
+
Interested in our consulting work? You can find us here: [https://www.modernistik.com](https://www.modernistik.com)
|
2616
|
+
|
2616
2617
|
## Contributing
|
2617
2618
|
|
2618
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/modernistik/parse-stack.
|
2619
|
+
Bug reports and pull requests are welcome on GitHub at [https://github.com/modernistik/parse-stack](https://github.com/modernistik/parse-stack).
|
2619
2620
|
|
2620
2621
|
## License
|
2621
2622
|
|
data/lib/parse/api/objects.rb
CHANGED
@@ -39,9 +39,9 @@ module Parse
|
|
39
39
|
uri = "#{CLASS_PATH_PREFIX}#{className}"
|
40
40
|
class_prefix = className.downcase.to_sym
|
41
41
|
if PREFIX_MAP.has_key?(class_prefix)
|
42
|
-
uri =
|
42
|
+
uri = PREFIX_MAP[class_prefix]
|
43
43
|
end
|
44
|
-
id.present? ? "#{uri}/#{id}" : uri
|
44
|
+
id.present? ? "#{uri}/#{id}" : "#{uri}/"
|
45
45
|
end
|
46
46
|
|
47
47
|
end
|
@@ -129,10 +129,12 @@ module Parse
|
|
129
129
|
set_attribute_method = :"#{key}_set_attribute!"
|
130
130
|
|
131
131
|
if self.fields[key].present? && Parse::Properties::BASE_FIELD_MAP[key].nil?
|
132
|
-
|
132
|
+
warn "Belongs relation #{self}##{key} already defined with type #{klassName}"
|
133
|
+
return false
|
133
134
|
end
|
134
135
|
if self.fields[parse_field].present?
|
135
|
-
|
136
|
+
warn "Alias belongs_to #{self}##{parse_field} conflicts with previously defined property."
|
137
|
+
return false
|
136
138
|
end
|
137
139
|
# store this attribute in the attributes hash with the proper remote column name.
|
138
140
|
# we know the type is pointer.
|
@@ -172,7 +174,7 @@ module Parse
|
|
172
174
|
end
|
173
175
|
|
174
176
|
if self.method_defined?("#{key}?")
|
175
|
-
|
177
|
+
warn "Creating belongs_to helper :#{key}?. Will overwrite existing method #{self}##{key}?."
|
176
178
|
end
|
177
179
|
|
178
180
|
define_method("#{key}?") do
|
@@ -360,6 +360,18 @@ module Parse
|
|
360
360
|
"#<#{self.class} changed?=#{changed?} @collection=#{@collection.inspect} >"
|
361
361
|
end
|
362
362
|
|
363
|
+
# Alias to `to_a.parse_objects` from Array#parse_objects
|
364
|
+
# @return [Array<Parse::Object>] an array of Parse Object subclasses representing this collection.
|
365
|
+
def parse_objects
|
366
|
+
collection.to_a.parse_objects
|
367
|
+
end
|
368
|
+
|
369
|
+
# Alias to `to_a.parse_pointers` from Array#parse_pointers
|
370
|
+
# @return [Array<Parse::Pointer>] an array of pointers representing this collection.
|
371
|
+
def parse_pointers
|
372
|
+
collection.to_a.parse_pointers
|
373
|
+
end
|
374
|
+
|
363
375
|
end
|
364
376
|
|
365
377
|
|
@@ -426,10 +426,12 @@ module Parse
|
|
426
426
|
|
427
427
|
# verify that the user did not duplicate properties or defined different properties with the same name
|
428
428
|
if self.fields[key].present? && Parse::Properties::BASE_FIELD_MAP[key].nil?
|
429
|
-
|
429
|
+
warn "Has_many property #{self}##{key} already defined with type #{klassName}"
|
430
|
+
return false
|
430
431
|
end
|
431
432
|
if self.fields[parse_field].present?
|
432
|
-
|
433
|
+
warn "Alias has_many #{self}##{parse_field} conflicts with previously defined property."
|
434
|
+
return false
|
433
435
|
end
|
434
436
|
# validations
|
435
437
|
validates_presence_of(key) if opts[:required]
|
@@ -122,7 +122,7 @@ module Parse
|
|
122
122
|
ivar = :"@_has_one_#{key}"
|
123
123
|
|
124
124
|
if self.method_defined?(key)
|
125
|
-
|
125
|
+
warn "Creating has_one :#{key} association. Will overwrite existing method #{self}##{key}."
|
126
126
|
end
|
127
127
|
|
128
128
|
define_method(key) do |*args, &block|
|
@@ -62,7 +62,7 @@ module Parse
|
|
62
62
|
if data_type == :pointer
|
63
63
|
klass.belongs_to key, as: type[:targetClass], field: field
|
64
64
|
elsif data_type == :relation
|
65
|
-
klass.has_many key, as: type[:targetClass], field: field
|
65
|
+
klass.has_many key, through: :relation, as: type[:targetClass], field: field
|
66
66
|
else
|
67
67
|
klass.property key, data_type, field: field
|
68
68
|
end
|
@@ -159,7 +159,7 @@ module Parse
|
|
159
159
|
self.fields.merge!( key => data_type, parse_field => data_type )
|
160
160
|
# This creates a mapping between the local field and the remote field name.
|
161
161
|
self.field_map.merge!( key => parse_field )
|
162
|
-
|
162
|
+
|
163
163
|
# if the field is marked as required, then add validations
|
164
164
|
if opts[:required]
|
165
165
|
# if integer or float, validate that it's a number
|
@@ -359,7 +359,7 @@ module Parse
|
|
359
359
|
end
|
360
360
|
|
361
361
|
if self.method_defined?("#{key}_decrement!")
|
362
|
-
|
362
|
+
warn "Creating decrement helper :#{key}_decrement!. Will overwrite existing method #{self}##{key}_decrement!."
|
363
363
|
end
|
364
364
|
|
365
365
|
define_method("#{key}_decrement!") do |amount = -1|
|
data/lib/parse/model/date.rb
CHANGED
@@ -15,13 +15,7 @@ require_relative 'model'
|
|
15
15
|
|
16
16
|
module Parse
|
17
17
|
# This class manages dates in the special JSON format it requires for
|
18
|
-
# properties of type _:date_.
|
19
|
-
# columns do not follow this convention all the time. Depending on the
|
20
|
-
# Cloud Code SDK, they can be the Parse ISO hash date format or the `iso8601`
|
21
|
-
# string format. By default, these are serialized as `iso8601` when sent as
|
22
|
-
# responses to Parse for backwards compatibility with some clients. To use
|
23
|
-
# the Parse ISO hash format for these fields instead, set
|
24
|
-
# `Parse::Object.disable_serialized_string_date = true`.
|
18
|
+
# properties of type _:date_.
|
25
19
|
class Date < ::DateTime
|
26
20
|
# The default attributes in a Parse Date hash.
|
27
21
|
ATTRIBUTES = { __type: :string, iso: :string }.freeze
|
data/lib/parse/model/object.rb
CHANGED
@@ -184,12 +184,8 @@ module Parse
|
|
184
184
|
# to set it to something different.
|
185
185
|
class << self
|
186
186
|
|
187
|
-
attr_accessor :
|
187
|
+
attr_accessor :parse_class
|
188
188
|
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
189
|
|
194
190
|
# The class method to override the implicitly assumed Parse collection name
|
195
191
|
# in your Parse database. The default Parse collection name is the singular form
|
@@ -509,20 +505,6 @@ module Parse
|
|
509
505
|
# @return [ACL] the access control list (permissions) object for this record.
|
510
506
|
property :acl, :acl, field: :ACL
|
511
507
|
|
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
508
|
# Access the value for a defined property through hash accessor. This method
|
527
509
|
# returns nil if the key is not one of the defined properties for this Parse::Object
|
528
510
|
# subclass.
|
@@ -546,6 +528,18 @@ module Parse
|
|
546
528
|
|
547
529
|
end
|
548
530
|
|
531
|
+
end
|
532
|
+
|
533
|
+
class Hash
|
534
|
+
|
535
|
+
# Turns a Parse formatted JSON hash into a Parse-Stack class object, if one is found.
|
536
|
+
# This is equivalent to calling `Parse::Object.build` on the hash object itself, but allows
|
537
|
+
# for doing this in loops, such as `map` when using symbol to proc. However, you can also use
|
538
|
+
# the Array extension `Array#parse_objects` for doing that more safely.
|
539
|
+
# @return [Parse::Object] A Parse::Object subclass represented the built class.
|
540
|
+
def parse_object
|
541
|
+
Parse::Object.build(self)
|
542
|
+
end
|
549
543
|
|
550
544
|
end
|
551
545
|
|
data/lib/parse/stack.rb
CHANGED
@@ -11,13 +11,18 @@ require_relative 'webhooks'
|
|
11
11
|
module Parse
|
12
12
|
class Error < StandardError; end;
|
13
13
|
module Stack
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
# Special class to support Modernistik Hyperdrive server.
|
18
|
+
class Hyperdrive
|
14
19
|
# Applies a remote JSON hash containing the ENV keys and values from a remote
|
15
20
|
# URL. Values from the JSON hash are only applied to the current ENV hash ONLY if
|
16
21
|
# it does not already have a value. Therefore local ENV values will take precedence
|
17
22
|
# over remote ones. By default, it uses the url in environment value in 'CONFIG_URL' or 'HYPERDRIVE_URL'.
|
18
23
|
# @param url [String] the remote url that responds with the JSON body.
|
19
24
|
# @return [Boolean] true if the JSON hash was found and applied successfully.
|
20
|
-
def self.
|
25
|
+
def self.config!(url = nil)
|
21
26
|
url ||= ENV["HYPERDRIVE_URL"] || ENV['CONFIG_URL']
|
22
27
|
if url.present?
|
23
28
|
begin
|
data/lib/parse/stack/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: parse-stack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anthony Persaud
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -275,7 +275,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
275
275
|
version: '0'
|
276
276
|
requirements: []
|
277
277
|
rubyforge_project:
|
278
|
-
rubygems_version: 2.6
|
278
|
+
rubygems_version: 2.7.6
|
279
279
|
signing_key:
|
280
280
|
specification_version: 4
|
281
281
|
summary: Parse Server Ruby Client SDK
|