Skip to content

Commit

Permalink
All array properties will return a default collection proxy if nil.
Browse files Browse the repository at this point in the history
  • Loading branch information
apersaud committed Aug 10, 2017
1 parent ed99c10 commit 8ce7768
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

### 1.7.2
- FIXED: first_or_create will now apply dirty tracking to newly created fields.
- FIXED: Properties of :array type will always return a Parse::CollectionProxy if their internal value is nil. The object will not be marked dirty until something is added to the array.
- NEW: `Parse::Model.autosave_on_create` has been removed in favor of `first_or_create!`.
- FIXED: Encoding a Parse::Object into JSON will remove any values that are `nil`
which were not explicitly changed to that value.
Expand Down
6 changes: 6 additions & 0 deletions lib/parse/model/core/properties.rb
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,12 @@ def property(key, data_type = :string, **opts)
# lets set the variable with the updated value
instance_variable_set ivar, value
send will_change_method
elsif value.nil? && data_type == :array
value = Parse::CollectionProxy.new [], delegate: self, key: key
instance_variable_set ivar, value
# don't send the notification yet until they actually add something
# which will be handled by the collection proxy.
# send will_change_method
end

# if the value is a String (like an iso8601 date) and the data type of
Expand Down

0 comments on commit 8ce7768

Please sign in to comment.