parse-stack 1.2 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Changes.md +7 -0
- data/Gemfile.lock +47 -5
- data/README.md +40 -6
- data/lib/parse/client.rb +1 -0
- data/lib/parse/model/associations/belongs_to.rb +5 -1
- data/lib/parse/model/associations/has_many.rb +6 -1
- data/lib/parse/model/core/properties.rb +2 -0
- data/lib/parse/model/object.rb +1 -0
- data/lib/parse/stack/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9f0d4895395a8d71c15ada27009a1176791a1604
|
|
4
|
+
data.tar.gz: c9bac3568ea1963c7972b4a32013a7d322324681
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0256eee4e1a40e2f3ad3eb6918a4875d4bd1fe2a3a034e4bbbe0e1bd16bebeb465a886859c490a267b7298e64492c164c4fa2c0f3a67be4c8ec599d4e5c47b7e
|
|
7
|
+
data.tar.gz: d8ac611c347806df930d7a1a5ba75530dc94268d5425ef970aba6db5efc7df2c57026c13f0356b5ebdc5388edabea90a64a785359982a5a0ee2186697c3643e4
|
data/Changes.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Parse-Stack Changes
|
|
2
2
|
|
|
3
|
+
1.2.1
|
|
4
|
+
-----------
|
|
5
|
+
- Add active support string dependencies.
|
|
6
|
+
- Support for handling the `Delete` operation on belongs_to
|
|
7
|
+
and has_many relationships.
|
|
8
|
+
- Documentation changes for supported Parse atomic operations.
|
|
9
|
+
|
|
3
10
|
1.2
|
|
4
11
|
-----------
|
|
5
12
|
- Fixes issues with first_or_create.
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
parse-stack (1.2)
|
|
4
|
+
parse-stack (1.2.1)
|
|
5
5
|
active_model_serializers (>= 0.9, < 1)
|
|
6
6
|
activemodel (>= 4.2.1, < 5)
|
|
7
7
|
activesupport (>= 4.2.1, < 5)
|
|
@@ -14,8 +14,24 @@ PATH
|
|
|
14
14
|
GEM
|
|
15
15
|
remote: https://rubygems.org/
|
|
16
16
|
specs:
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
actionpack (4.2.6)
|
|
18
|
+
actionview (= 4.2.6)
|
|
19
|
+
activesupport (= 4.2.6)
|
|
20
|
+
rack (~> 1.6)
|
|
21
|
+
rack-test (~> 0.6.2)
|
|
22
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
|
23
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
|
24
|
+
actionview (4.2.6)
|
|
25
|
+
activesupport (= 4.2.6)
|
|
26
|
+
builder (~> 3.1)
|
|
27
|
+
erubis (~> 2.7.0)
|
|
28
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
|
29
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
|
30
|
+
active_model_serializers (0.10.1)
|
|
31
|
+
actionpack (>= 4.1, < 6)
|
|
32
|
+
activemodel (>= 4.1, < 6)
|
|
33
|
+
jsonapi (~> 0.1.1.beta2)
|
|
34
|
+
railties (>= 4.1, < 6)
|
|
19
35
|
activemodel (4.2.6)
|
|
20
36
|
activesupport (= 4.2.6)
|
|
21
37
|
builder (~> 3.1)
|
|
@@ -31,17 +47,27 @@ GEM
|
|
|
31
47
|
coderay (1.1.1)
|
|
32
48
|
debug_inspector (0.0.2)
|
|
33
49
|
dotenv (2.1.1)
|
|
50
|
+
erubis (2.7.0)
|
|
34
51
|
faraday (0.9.2)
|
|
35
52
|
multipart-post (>= 1.2, < 3)
|
|
36
53
|
faraday_middleware (0.10.0)
|
|
37
54
|
faraday (>= 0.7.4, < 0.10)
|
|
38
55
|
i18n (0.7.0)
|
|
39
56
|
json (1.8.3)
|
|
57
|
+
jsonapi (0.1.1.beta2)
|
|
58
|
+
json (~> 1.8)
|
|
59
|
+
loofah (2.0.3)
|
|
60
|
+
nokogiri (>= 1.5.9)
|
|
40
61
|
method_source (0.8.2)
|
|
41
|
-
|
|
62
|
+
mini_portile2 (2.1.0)
|
|
63
|
+
minitest (5.9.0)
|
|
42
64
|
moneta (0.8.0)
|
|
43
65
|
multipart-post (2.0.0)
|
|
44
|
-
|
|
66
|
+
nokogiri (1.6.8)
|
|
67
|
+
mini_portile2 (~> 2.1.0)
|
|
68
|
+
pkg-config (~> 1.1.7)
|
|
69
|
+
parallel (1.9.0)
|
|
70
|
+
pkg-config (1.1.7)
|
|
45
71
|
pry (0.10.3)
|
|
46
72
|
coderay (~> 1.1.0)
|
|
47
73
|
method_source (~> 0.8.1)
|
|
@@ -52,8 +78,24 @@ GEM
|
|
|
52
78
|
binding_of_caller (>= 0.7)
|
|
53
79
|
pry (>= 0.9.11)
|
|
54
80
|
rack (1.6.4)
|
|
81
|
+
rack-test (0.6.3)
|
|
82
|
+
rack (>= 1.0)
|
|
83
|
+
rails-deprecated_sanitizer (1.0.3)
|
|
84
|
+
activesupport (>= 4.2.0.alpha)
|
|
85
|
+
rails-dom-testing (1.0.7)
|
|
86
|
+
activesupport (>= 4.2.0.beta, < 5.0)
|
|
87
|
+
nokogiri (~> 1.6.0)
|
|
88
|
+
rails-deprecated_sanitizer (>= 1.0.1)
|
|
89
|
+
rails-html-sanitizer (1.0.3)
|
|
90
|
+
loofah (~> 2.0)
|
|
91
|
+
railties (4.2.6)
|
|
92
|
+
actionpack (= 4.2.6)
|
|
93
|
+
activesupport (= 4.2.6)
|
|
94
|
+
rake (>= 0.8.7)
|
|
95
|
+
thor (>= 0.18.1, < 2.0)
|
|
55
96
|
rake (10.5.0)
|
|
56
97
|
slop (3.6.0)
|
|
98
|
+
thor (0.19.1)
|
|
57
99
|
thread_safe (0.3.5)
|
|
58
100
|
tzinfo (1.2.2)
|
|
59
101
|
thread_safe (~> 0.1)
|
data/README.md
CHANGED
|
@@ -301,12 +301,11 @@ class Post < Parse::Object
|
|
|
301
301
|
# maybe a count of comments.
|
|
302
302
|
property :comment_count, :integer, default: 0
|
|
303
303
|
|
|
304
|
-
# the published date. Maps to "publishDate"
|
|
305
|
-
property :publish_date, :date, default: ->{ DateTime.now }
|
|
306
|
-
|
|
307
304
|
# use lambda to access the instance object.
|
|
308
305
|
# Set draft_date to the created_at date if empty.
|
|
309
306
|
property :draft_date, :date, default: lambda { |x| x.created_at }
|
|
307
|
+
# the published date. Maps to "publishDate"
|
|
308
|
+
property :publish_date, :date, default: lambda { |x| DateTime.now }
|
|
310
309
|
|
|
311
310
|
# maybe whether it is currently visible
|
|
312
311
|
property :visible, :boolean
|
|
@@ -378,7 +377,7 @@ class SomeClass < Parse::Object
|
|
|
378
377
|
# default value
|
|
379
378
|
property :category, default: "myValue"
|
|
380
379
|
# default value Proc style
|
|
381
|
-
property :date, default:
|
|
380
|
+
property :date, default: lambda { |x| DateTime.now }
|
|
382
381
|
end
|
|
383
382
|
```
|
|
384
383
|
###### `:alias => (true|false)`
|
|
@@ -486,8 +485,9 @@ class Band < Parse::Object
|
|
|
486
485
|
property :category, :integer, default: 1
|
|
487
486
|
# assume any band as < 100 members
|
|
488
487
|
has_many :artists # assumes `through: :array`
|
|
489
|
-
# bands can have millions of fans
|
|
490
|
-
|
|
488
|
+
# bands can have millions of fans (Parse::User objects),
|
|
489
|
+
# we use relations instead
|
|
490
|
+
has_many :fans, as: :user, through: :relation
|
|
491
491
|
end
|
|
492
492
|
|
|
493
493
|
# Find all bands which have a category in this array.
|
|
@@ -501,12 +501,41 @@ band = bands.first
|
|
|
501
501
|
# the number of fans in the relation
|
|
502
502
|
band.fans.count
|
|
503
503
|
|
|
504
|
+
# get the first object in relation
|
|
505
|
+
fan = bands.fans.first
|
|
506
|
+
|
|
507
|
+
# use `add` or `remove` to modify relations
|
|
508
|
+
band.fans.add Parse::User.first
|
|
509
|
+
# updates the relation as well as changes to `band`
|
|
510
|
+
band.fans.save
|
|
511
|
+
|
|
504
512
|
# Find 50 fans who are near San Diego, CA
|
|
505
513
|
downtown = Parse::GeoPoint.new(32.82, -117.23)
|
|
506
514
|
fans = band.fans.all(:location.near => downtown, :limit => 50)
|
|
507
515
|
|
|
508
516
|
```
|
|
509
517
|
|
|
518
|
+
You can perform atomic additions and removals of objects from `has_many` relations. Parse allows this by providing a specific atomic operation request. You can use the methods below to perform these types of atomic operations. __Note: The operation is performed directly on Parse server and not on your local object.__
|
|
519
|
+
|
|
520
|
+
```ruby
|
|
521
|
+
|
|
522
|
+
# atomically add/remove
|
|
523
|
+
band.artists.add! objects # { __op: :AddUnique }
|
|
524
|
+
band.artists.remove! objects # { __op: :AddUnique }
|
|
525
|
+
|
|
526
|
+
# atomically add unique Artist
|
|
527
|
+
band.artists.add_unique! objects # { __op: :AddUnique }
|
|
528
|
+
|
|
529
|
+
# atomically add/remove relations
|
|
530
|
+
band.fans.add! users # { __op: :Add }
|
|
531
|
+
band.fans.remove! users # { __op: :Remove }
|
|
532
|
+
|
|
533
|
+
# atomically perform a delete operation on this field name
|
|
534
|
+
# this should set it as `undefined`.
|
|
535
|
+
band.op_destroy!("category") # { __op: :Delete }
|
|
536
|
+
|
|
537
|
+
```
|
|
538
|
+
|
|
510
539
|
##### Options
|
|
511
540
|
Options for `has_many` are the same as the `belongs_to` counterpart with support for `:required`, `:as` and `:field`. It has this additional option of `:through` which helps specify whether it is an Array or Relation association type.
|
|
512
541
|
|
|
@@ -1156,9 +1185,14 @@ class Artist < Parse::Object
|
|
|
1156
1185
|
artist = payload.parse_object # Artist
|
|
1157
1186
|
# artist object will have dirty tracking information
|
|
1158
1187
|
|
|
1188
|
+
artist.new? # true if this is a new object
|
|
1189
|
+
|
|
1159
1190
|
# default San Diego
|
|
1160
1191
|
artist.location ||= Parse::GeoPoint.new(32.82, -117.23)
|
|
1161
1192
|
|
|
1193
|
+
# raise to fail the save
|
|
1194
|
+
raise "Name cannot be empty" if artist.name.blank?
|
|
1195
|
+
|
|
1162
1196
|
if artist.name_changed?
|
|
1163
1197
|
# .. do something if `name` has changed
|
|
1164
1198
|
end
|
data/lib/parse/client.rb
CHANGED
|
@@ -86,12 +86,16 @@ module Parse
|
|
|
86
86
|
|
|
87
87
|
# We only support pointers, either by object or by transforming a hash.
|
|
88
88
|
define_method("#{key}_set_attribute!") do |val, track = true|
|
|
89
|
-
if val
|
|
89
|
+
if val == Parse::Properties::DELETE_OP
|
|
90
|
+
val = nil
|
|
91
|
+
elsif val.is_a?(Hash) && ( val["__type"].freeze == "Pointer".freeze || val["__type"].freeze == "Object".freeze )
|
|
90
92
|
val = Parse::Object.build val, ( val["className"] || klassName )
|
|
91
93
|
end
|
|
94
|
+
|
|
92
95
|
if track == true
|
|
93
96
|
send :"#{key}_will_change!" unless val == instance_variable_get( :"@#{key}" )
|
|
94
97
|
end
|
|
98
|
+
|
|
95
99
|
# Never set an object that is not a Parse::Pointer
|
|
96
100
|
if val.nil? || val.is_a?(Parse::Pointer)
|
|
97
101
|
instance_variable_set(:"@#{key}", val)
|
|
@@ -123,7 +123,12 @@ module Parse
|
|
|
123
123
|
define_method("#{key}_set_attribute!") do |val, track = true|
|
|
124
124
|
# If it is a hash, with a __type of Relation, createa a new RelationCollectionProxy, regardless
|
|
125
125
|
# of what is defined because we must have gotten this from Parse.
|
|
126
|
-
|
|
126
|
+
|
|
127
|
+
# if val is nil or it is the delete operation, then set to empty array.
|
|
128
|
+
# this will create a new proxyKlass later on
|
|
129
|
+
if val.nil? || val == Parse::Properties::DELETE_OP
|
|
130
|
+
val = []
|
|
131
|
+
end
|
|
127
132
|
|
|
128
133
|
if val.is_a?(Hash) && val["__type"] == "Relation"
|
|
129
134
|
relation_objects = val["objects"] || []
|
|
@@ -30,6 +30,8 @@ module Parse
|
|
|
30
30
|
# Default hash map of local attribute name to remote column name
|
|
31
31
|
BASE_FIELD_MAP = {id: :objectId, created_at: :createdAt, updated_at: :updatedAt, acl: :ACL}.freeze
|
|
32
32
|
|
|
33
|
+
DELETE_OP = {"__op"=>"Delete"}.freeze
|
|
34
|
+
|
|
33
35
|
def self.included(base)
|
|
34
36
|
base.extend(ClassMethods)
|
|
35
37
|
end
|
data/lib/parse/model/object.rb
CHANGED
data/lib/parse/stack/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: parse-stack
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 1.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Anthony Persaud
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: exe
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2016-06-
|
|
12
|
+
date: 2016-06-22 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: activemodel
|