lib/glimmer/data_binding/observable_array.rb in glimmer-1.0.2 vs lib/glimmer/data_binding/observable_array.rb in glimmer-1.0.3
- old
+ new
@@ -1,18 +1,18 @@
# Copyright (c) 2007-2020 Andy Maleh
-#
+#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
-#
+#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
@@ -46,11 +46,11 @@
end
def add_element_observer(element, observer)
element_properties_for(observer).each do |property|
observer.observe(element, property)
- end
+ end
end
def remove_observer(observer, *element_properties)
element_properties = element_properties.flatten.compact.uniq
if !element_properties.empty?
@@ -60,24 +60,24 @@
end
if element_properties_for(observer).empty?
property_observer_list.delete(observer)
observer_element_properties.delete(observer)
each { |element| remove_element_observer(element, observer) }
- end
+ end
observer
end
def remove_element_observers(element)
property_observer_list.each do |observer|
remove_element_observer(element, observer)
- end
+ end
end
def remove_element_observer(element, observer)
element_properties_for(observer).each do |property|
observer.unobserve(element, property)
- end
+ end
end
def has_observer?(observer)
property_observer_list.include?(observer)
end
@@ -102,22 +102,22 @@
property_observer_list.to_a.each(&:call)
end
def <<(element)
super(element).tap do
- add_element_observers(element)
+ add_element_observers(element)
notify_observers
end
end
alias push <<
alias append <<
def []=(index, value)
old_value = self[index]
unregister_dependent_observers(old_value)
remove_element_observers(old_value)
- add_element_observers(value)
+ add_element_observers(value)
super(index, value).tap do
notify_observers
end
end
@@ -149,11 +149,11 @@
def delete_if(&block)
if block_given?
old_array = Array.new(self)
super(&block).tap do |new_array|
- (old_array - new_array).each do |element|
+ (old_array - new_array).each do |element|
unregister_dependent_observers(element)
remove_element_observers(element)
end
notify_observers
end
@@ -262,10 +262,10 @@
end
end
def unshift(element)
super(element).tap do
- add_element_observers(element)
+ add_element_observers(element)
notify_observers
end
end
alias prepend unshift