parse-stack 1.0.5 → 1.0.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 93fb8b8b1962db48f30eb4e1ae2f7172b8377ed6
4
- data.tar.gz: 8dbf85b25286a790c48d88dbc52228bbf8a66838
3
+ metadata.gz: f726df2468ce8619a3b0a3f85a256394f0a80563
4
+ data.tar.gz: 9834d706f674c86f05ab893601c48eef4a7dfebb
5
5
  SHA512:
6
- metadata.gz: 3768e70a0e368697101e6a6d12e178cae15593950441876999b4e01377aa14ebb721be405d910651ffa399b5e6d760fa7f7a47b268665b760e5b47f4704f1b59
7
- data.tar.gz: 56cb920091be91a880acd7667732f7d90f88fcd6dc174a7bd0bd5048b336a5538713f1117e0a5149beec612c13802669b1b28452bf4a9279a666d34f2f1dbe5e
6
+ metadata.gz: c3fb7521b9c7d48429672421aedbfb421315e4e0b735926d9c808460a26ed6cff002297bf4a8160aa532b0f0f78c0b09c51b9345f60bfb43f97b11de18480c6d
7
+ data.tar.gz: db348ac32092c177321a8aba58979db324390bd748cbdb75a80ef2184cc9d789c0514d8d800cf282175340b284c6fd3e3cef13fd3aa7cf4d32b3a72953e80af0
data/Changes.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Parse-Stack Changes
2
2
 
3
+ 1.0.6
4
+ -----------
5
+ - Fixes issue when making batch requests with special prefix url.
6
+ - Adds Parse::ConnectionError custom exception type.
7
+ - You can call locally registered cloud functions with
8
+ Parse::Webhooks.run_function(:functionName, params) without going through the
9
+ entire Parse API network stack.
10
+ - `:symbolize => true` now works for `:array` data types. All items in the collection
11
+ will be symbolized - useful for array of strings.
12
+ - Prevent ACLs from causing an autofetch.
13
+ - Empty strings, arrays and `false` are now working with `:default` option in properties.
14
+
3
15
  1.0.5
4
16
  -----------
5
17
  - Defaults are applied on object instantiation.
@@ -10,7 +22,7 @@
10
22
  - Fixes minor issue when storing and retrieving objects from the cache.
11
23
  - Support for providing :server_url as a connection option for those migrating hosting
12
24
  their own parse-server.
13
-
25
+
14
26
  1.0.3
15
27
  -----------
16
28
  - Fixes minor issue when passing `nil` to the class `find` method.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- parse-stack (1.0.5)
4
+ parse-stack (1.0.6)
5
5
  active_model_serializers (>= 0.9, < 1)
6
6
  activemodel (>= 4, < 5)
7
7
  activesupport (>= 4, < 5)
@@ -8,6 +8,10 @@ require_relative "client/caching"
8
8
  require_relative "api/all"
9
9
 
10
10
  module Parse
11
+
12
+ # This is an exception that is thrown if there is a client connectivity issue
13
+ class ConnectionError < Exception; end;
14
+
11
15
  # Main class for the client. The client class is based on a Faraday stack.
12
16
  # The Faraday stack is similar to a Rack-style application in which you can define middlewares
13
17
  # that will be called for each request going out and coming back in. We use this in order to setup
@@ -111,6 +115,10 @@ module Parse
111
115
  self
112
116
  end
113
117
 
118
+ def url_prefix
119
+ @session.url_prefix
120
+ end
121
+
114
122
  def clear_cache!
115
123
  self.cache.clear if self.cache.present?
116
124
  end
@@ -76,6 +76,10 @@ module Parse
76
76
  collection.to_a
77
77
  end; alias_method :to_a, :to_ary
78
78
 
79
+ def set_collection!(list)
80
+ @collection = list
81
+ end
82
+
79
83
  # lazy loading of a collection. If empty and not loaded, then forward _fetch!
80
84
  # to the delegate
81
85
  def collection
@@ -190,12 +190,15 @@ module Parse
190
190
  # This creates a destroy_request for the current object.
191
191
  def destroy_request
192
192
  return nil unless @id.present?
193
- uri = Client.uri_path(self)
193
+ uri = self.uri_path
194
194
  r = Request.new( :delete, uri )
195
195
  r.tag = object_id
196
196
  r
197
197
  end
198
198
 
199
+ def uri_path
200
+ self.client.url_prefix.path + Client.uri_path(self)
201
+ end
199
202
  # Creates an array of all possible PUT operations that need to be performed
200
203
  # on this local object. The reason it is a list is because attribute operations,
201
204
  # relational add operations and relational remove operations are treated as separate
@@ -203,7 +206,7 @@ module Parse
203
206
  def change_requests(force = false)
204
207
  requests = []
205
208
  # get the URI path for this object.
206
- uri = Client.uri_path(self)
209
+ uri = self.uri_path
207
210
 
208
211
  # generate the request to update the object (PUT)
209
212
  if attribute_changes? || force
@@ -436,7 +439,7 @@ module Parse
436
439
  def autofetch!(key)
437
440
  key = key.to_sym
438
441
  @fetch_lock ||= false
439
- if @fetch_lock != true && pointer? && Parse::Properties::BASE_KEYS.include?(key) == false && respond_to?(:fetch)
442
+ if @fetch_lock != true && pointer? && key != :acl && Parse::Properties::BASE_KEYS.include?(key) == false && respond_to?(:fetch)
440
443
  @fetch_lock = true
441
444
  send :fetch
442
445
  @fetch_lock = false
@@ -133,8 +133,8 @@ module Parse
133
133
  symbolize_value = opts[:symbolize]
134
134
 
135
135
  #only support symbolization of string data types
136
- if symbolize_value && data_type != :string
137
- raise 'Symbolization is only supported on :string data types.'
136
+ if symbolize_value && (data_type == :string || data_type == :array) == false
137
+ raise 'Symbolization is only supported on :string or :array data types.'
138
138
  end
139
139
 
140
140
  # Here is the where the 'magic' begins. For each property defined, we will
@@ -142,7 +142,7 @@ module Parse
142
142
  # helpers.
143
143
  # get the default value if provided (or Proc)
144
144
  default_value = opts[:default]
145
- if default_value.present?
145
+ unless default_value.nil?
146
146
  defaults_list.push(key) if default_value.present?
147
147
 
148
148
  define_method("#{key}_default") do
@@ -189,7 +189,16 @@ module Parse
189
189
  send "#{key}_will_change!"
190
190
  end
191
191
  # finally return the value
192
- symbolize_value && value.respond_to?(:to_sym) ? value.to_sym : value
192
+ if symbolize_value
193
+ if data_type == :string
194
+ return value.respond_to?(:to_sym) ? value.to_sym : value
195
+ elsif data_type == :array && value.is_a?(Array)
196
+ # value.map(&:to_sym)
197
+ return value.compact.map { |m| m.respond_to?(:to_sym) ? m.to_sym : m }
198
+ end
199
+ end
200
+
201
+ value
193
202
  end
194
203
 
195
204
  # The second method to be defined is a setter method. This is done by
@@ -215,9 +224,15 @@ module Parse
215
224
  if track == true
216
225
  send :"#{key}_will_change!" unless val == instance_variable_get( :"@#{key}" )
217
226
  end
218
- if symbolize_value && data_type == :string
219
- val = nil if val.blank?
220
- val = val.to_sym if val.respond_to?(:to_sym)
227
+
228
+ if symbolize_value
229
+ if data_type == :string
230
+ val = nil if val.blank?
231
+ val = val.to_sym if val.respond_to?(:to_sym)
232
+ elsif val.is_a?(Parse::CollectionProxy)
233
+ items = val.collection.map { |m| m.respond_to?(:to_sym) ? m.to_sym : m }
234
+ val.set_collection! items
235
+ end
221
236
  end
222
237
  # now set the instance value
223
238
  instance_variable_set :"@#{key}", val
@@ -1,5 +1,5 @@
1
1
  module Parse
2
2
  module Stack
3
- VERSION = "1.0.5"
3
+ VERSION = "1.0.6"
4
4
  end
5
5
  end
@@ -121,6 +121,13 @@ module Parse
121
121
  #puts "Webhook: #{type} -> #{className}..."
122
122
  end
123
123
 
124
+ def run_function(name, params)
125
+ payload = Payload.new
126
+ payload.function_name = name
127
+ payload.params = params
128
+ call_route(:function, name, payload)
129
+ end
130
+
124
131
  def call_route(type, className, payload = nil)
125
132
  type = type.to_s.underscore.to_sym #support camelcase
126
133
  className = className.parse_class if className.respond_to?(:parse_class)
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: 1.0.5
4
+ version: 1.0.6
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-02-13 00:00:00.000000000 Z
12
+ date: 2016-02-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemodel