Skip to content

Commit

Permalink
Fix for atomic ops on NoBrainer::Array (and any other Array subclasses)
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeMonkeySteve committed Mar 5, 2023
1 parent 8f9b01e commit fa3e07e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/no_brainer/document/atomic_ops.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ def self._new(instance, field, value, is_user_value)
type ||= value.class unless value.nil?

case
when type == Array then PendingAtomicArray
when type.nil? then self
when type <= Array then PendingAtomicArray
when type == Set then PendingAtomicSet
else self
end.new(instance, field, value, is_user_value, type)
Expand All @@ -26,7 +27,8 @@ def initialize(instance, field, value, is_user_value, type)

def default_value
case
when @type == Array then []
when @type.nil? then nil
when @type <= Array then []
when @type == Set then []
when @type == Integer then 0
when @type == Float then 0.0
Expand Down

0 comments on commit fa3e07e

Please sign in to comment.