glimmer 0.8.2 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +1 -1
  3. data/README.md +116 -95
  4. data/VERSION +1 -1
  5. data/lib/glimmer.rb +0 -20
  6. data/lib/glimmer/config.rb +0 -13
  7. data/lib/glimmer/dsl/engine.rb +25 -18
  8. data/lib/glimmer/dsl/expression.rb +0 -7
  9. data/lib/glimmer/dsl/static_expression.rb +2 -2
  10. metadata +47 -177
  11. data/RUBY_VERSION +0 -1
  12. data/bin/girb +0 -10
  13. data/bin/girb_runner.rb +0 -13
  14. data/bin/glimmer +0 -5
  15. data/icons/scaffold_app.icns +0 -0
  16. data/lib/glimmer/css/rule.rb +0 -25
  17. data/lib/glimmer/css/style_sheet.rb +0 -19
  18. data/lib/glimmer/data_binding/list_selection_binding.rb +0 -52
  19. data/lib/glimmer/data_binding/model_binding.rb +0 -248
  20. data/lib/glimmer/data_binding/observable.rb +0 -21
  21. data/lib/glimmer/data_binding/observable_array.rb +0 -107
  22. data/lib/glimmer/data_binding/observable_model.rb +0 -108
  23. data/lib/glimmer/data_binding/observable_widget.rb +0 -17
  24. data/lib/glimmer/data_binding/observer.rb +0 -124
  25. data/lib/glimmer/data_binding/shine.rb +0 -23
  26. data/lib/glimmer/data_binding/table_items_binding.rb +0 -56
  27. data/lib/glimmer/data_binding/tree_items_binding.rb +0 -71
  28. data/lib/glimmer/data_binding/widget_binding.rb +0 -33
  29. data/lib/glimmer/dsl/css/css_expression.rb +0 -21
  30. data/lib/glimmer/dsl/css/dsl.rb +0 -10
  31. data/lib/glimmer/dsl/css/dynamic_property_expression.rb +0 -12
  32. data/lib/glimmer/dsl/css/property_expression.rb +0 -22
  33. data/lib/glimmer/dsl/css/pv_expression.rb +0 -17
  34. data/lib/glimmer/dsl/css/rule_expression.rb +0 -25
  35. data/lib/glimmer/dsl/css/s_expression.rb +0 -26
  36. data/lib/glimmer/dsl/swt/async_exec_expression.rb +0 -14
  37. data/lib/glimmer/dsl/swt/bind_expression.rb +0 -37
  38. data/lib/glimmer/dsl/swt/color_expression.rb +0 -19
  39. data/lib/glimmer/dsl/swt/column_properties_expression.rb +0 -24
  40. data/lib/glimmer/dsl/swt/combo_selection_data_binding_expression.rb +0 -42
  41. data/lib/glimmer/dsl/swt/custom_widget_expression.rb +0 -36
  42. data/lib/glimmer/dsl/swt/data_binding_expression.rb +0 -34
  43. data/lib/glimmer/dsl/swt/dialog_expression.rb +0 -26
  44. data/lib/glimmer/dsl/swt/display_expression.rb +0 -19
  45. data/lib/glimmer/dsl/swt/dsl.rb +0 -28
  46. data/lib/glimmer/dsl/swt/exec_expression.rb +0 -28
  47. data/lib/glimmer/dsl/swt/layout_data_expression.rb +0 -25
  48. data/lib/glimmer/dsl/swt/layout_expression.rb +0 -27
  49. data/lib/glimmer/dsl/swt/list_selection_data_binding_expression.rb +0 -44
  50. data/lib/glimmer/dsl/swt/menu_bar_expression.rb +0 -33
  51. data/lib/glimmer/dsl/swt/menu_expression.rb +0 -32
  52. data/lib/glimmer/dsl/swt/message_box_expression.rb +0 -29
  53. data/lib/glimmer/dsl/swt/observe_expression.rb +0 -32
  54. data/lib/glimmer/dsl/swt/property_expression.rb +0 -22
  55. data/lib/glimmer/dsl/swt/rgb_expression.rb +0 -12
  56. data/lib/glimmer/dsl/swt/rgba_expression.rb +0 -12
  57. data/lib/glimmer/dsl/swt/shell_expression.rb +0 -25
  58. data/lib/glimmer/dsl/swt/swt_expression.rb +0 -25
  59. data/lib/glimmer/dsl/swt/sync_exec_expression.rb +0 -15
  60. data/lib/glimmer/dsl/swt/tab_item_expression.rb +0 -33
  61. data/lib/glimmer/dsl/swt/table_items_data_binding_expression.rb +0 -31
  62. data/lib/glimmer/dsl/swt/tree_items_data_binding_expression.rb +0 -31
  63. data/lib/glimmer/dsl/swt/tree_properties_expression.rb +0 -26
  64. data/lib/glimmer/dsl/swt/widget_expression.rb +0 -35
  65. data/lib/glimmer/dsl/swt/widget_listener_expression.rb +0 -32
  66. data/lib/glimmer/dsl/xml/dsl.rb +0 -11
  67. data/lib/glimmer/dsl/xml/html_expression.rb +0 -25
  68. data/lib/glimmer/dsl/xml/meta_expression.rb +0 -23
  69. data/lib/glimmer/dsl/xml/name_space_expression.rb +0 -37
  70. data/lib/glimmer/dsl/xml/node_parent_expression.rb +0 -33
  71. data/lib/glimmer/dsl/xml/tag_expression.rb +0 -29
  72. data/lib/glimmer/dsl/xml/text_expression.rb +0 -22
  73. data/lib/glimmer/dsl/xml/xml_expression.rb +0 -21
  74. data/lib/glimmer/launcher.rb +0 -199
  75. data/lib/glimmer/package.rb +0 -55
  76. data/lib/glimmer/rake_task.rb +0 -58
  77. data/lib/glimmer/scaffold.rb +0 -582
  78. data/lib/glimmer/swt/color_proxy.rb +0 -53
  79. data/lib/glimmer/swt/display_proxy.rb +0 -88
  80. data/lib/glimmer/swt/font_proxy.rb +0 -72
  81. data/lib/glimmer/swt/layout_data_proxy.rb +0 -84
  82. data/lib/glimmer/swt/layout_proxy.rb +0 -82
  83. data/lib/glimmer/swt/menu_proxy.rb +0 -101
  84. data/lib/glimmer/swt/message_box_proxy.rb +0 -48
  85. data/lib/glimmer/swt/packages.rb +0 -13
  86. data/lib/glimmer/swt/shell_proxy.rb +0 -152
  87. data/lib/glimmer/swt/swt_proxy.rb +0 -106
  88. data/lib/glimmer/swt/tab_item_proxy.rb +0 -65
  89. data/lib/glimmer/swt/table_proxy.rb +0 -150
  90. data/lib/glimmer/swt/tree_proxy.rb +0 -120
  91. data/lib/glimmer/swt/widget_listener_proxy.rb +0 -34
  92. data/lib/glimmer/swt/widget_proxy.rb +0 -489
  93. data/lib/glimmer/ui/custom_shell.rb +0 -45
  94. data/lib/glimmer/ui/custom_widget.rb +0 -244
  95. data/lib/glimmer/util/proc_tracker.rb +0 -16
  96. data/lib/glimmer/xml/depth_first_search_iterator.rb +0 -22
  97. data/lib/glimmer/xml/name_space_visitor.rb +0 -21
  98. data/lib/glimmer/xml/node.rb +0 -75
  99. data/lib/glimmer/xml/node_visitor.rb +0 -13
  100. data/lib/glimmer/xml/xml_visitor.rb +0 -65
  101. data/vendor/swt/linux/swt.jar +0 -0
  102. data/vendor/swt/mac/swt.jar +0 -0
  103. data/vendor/swt/windows/swt.jar +0 -0
@@ -1,52 +0,0 @@
1
- require 'glimmer'
2
- require 'glimmer/data_binding/observable'
3
- require 'glimmer/data_binding/observer'
4
-
5
- module Glimmer
6
- module DataBinding
7
- # SWT List widget selection binding
8
- class ListSelectionBinding
9
- include Glimmer
10
- include Observable
11
- include Observer
12
-
13
- attr_reader :widget_proxy
14
-
15
- PROPERTY_TYPE_UPDATERS = {
16
- :string => lambda { |widget_proxy, value| widget_proxy.swt_widget.select(widget_proxy.swt_widget.index_of(value.to_s)) },
17
- :array => lambda { |widget_proxy, value| widget_proxy.swt_widget.selection=(value || []).to_java(:string) }
18
- }
19
-
20
- PROPERTY_EVALUATORS = {
21
- :string => lambda do |selection_array|
22
- return nil if selection_array.empty?
23
- selection_array[0]
24
- end,
25
- :array => lambda do |selection_array|
26
- selection_array
27
- end
28
- }
29
-
30
- # Initialize with list widget and property_type
31
- # property_type :string represents default list single selection
32
- # property_type :array represents list multi selection
33
- def initialize(widget_proxy, property_type)
34
- property_type = :string if property_type.nil? or property_type == :undefined
35
- @widget_proxy = widget_proxy
36
- @property_type = property_type
37
- @widget_proxy.on_widget_disposed do |dispose_event|
38
- unregister_all_observables
39
- end
40
- end
41
-
42
- def call(value)
43
- PROPERTY_TYPE_UPDATERS[@property_type].call(@widget_proxy, value) unless evaluate_property == value
44
- end
45
-
46
- def evaluate_property
47
- selection_array = @widget_proxy.swt_widget.send('selection').to_a #TODO refactor send('selection') into proper method invocation
48
- PROPERTY_EVALUATORS[@property_type].call(selection_array)
49
- end
50
- end
51
- end
52
- end
@@ -1,248 +0,0 @@
1
- require 'glimmer/data_binding/observable'
2
- require 'glimmer/data_binding/observer'
3
-
4
- module Glimmer
5
- module DataBinding
6
- class ModelBinding
7
- include Observable
8
- include Observer
9
-
10
- attr_reader :binding_options
11
-
12
- def initialize(base_model, property_name_expression, binding_options = nil)
13
- @base_model = base_model
14
- @property_name_expression = property_name_expression
15
- @binding_options = binding_options || {}
16
- if computed?
17
- @computed_model_bindings = computed_by.map do |computed_by_property_expression|
18
- self.class.new(base_model, computed_by_property_expression)
19
- end
20
- end
21
- end
22
-
23
- def model
24
- nested_property? ? nested_model : base_model
25
- end
26
-
27
- # e.g. person.address.state returns [person, person.address]
28
- def nested_models
29
- @nested_models = [base_model]
30
- model_property_names.reduce(base_model) do |reduced_model, nested_model_property_name|
31
- if reduced_model.nil?
32
- nil
33
- else
34
- invoke_property_reader(reduced_model, nested_model_property_name).tap do |new_reduced_model|
35
- @nested_models << new_reduced_model
36
- end
37
- end
38
- end
39
- @nested_models
40
- end
41
-
42
- def nested_model
43
- nested_models.last
44
- end
45
-
46
- def base_model
47
- @base_model
48
- end
49
-
50
- def property_name
51
- nested_property? ? nested_property_name : property_name_expression
52
- end
53
-
54
- def convert_on_read(value)
55
- apply_converter(@binding_options[:on_read], value)
56
- end
57
-
58
- def convert_on_write(value)
59
- apply_converter(@binding_options[:on_write], value)
60
- end
61
-
62
- def apply_converter(converter, value)
63
- if converter.nil?
64
- value
65
- elsif converter.is_a?(String) || converter.is_a?(Symbol)
66
- if value.respond_to?(converter)
67
- value.send(converter)
68
- else
69
- raise Glimmer::Error, "Unsupported bind converter: #{converter.inspect}"
70
- end
71
- elsif converter.respond_to?(:call, value)
72
- converter.call(value)
73
- else
74
- raise Glimmer::Error, "Unsupported bind converter: #{converter.inspect}"
75
- end
76
- end
77
-
78
- # All nested property names
79
- # e.g. property name expression "address.state" gives ['address', 'state']
80
- # If there are any indexed property names, this returns indexes as properties.
81
- # e.g. property name expression "addresses[1].state" gives ['addresses', '[1]', 'state']
82
- def nested_property_names
83
- @nested_property_names ||= property_name_expression.split(".").map {|pne| pne.match(/([^\[]+)(\[[^\]]+\])?/).to_a.drop(1)}.flatten.compact
84
- end
85
-
86
- # Final nested property name
87
- # e.g. property name expression "address.state" gives :state
88
- def nested_property_name
89
- nested_property_names.last
90
- end
91
-
92
- # Model representing nested property names
93
- # e.g. property name expression "address.state" gives [:address]
94
- def model_property_names
95
- nested_property_names[0...-1]
96
- end
97
-
98
- def nested_property?
99
- property_name_expression.match(/[.\[]/)
100
- end
101
-
102
- def property_name_expression
103
- @property_name_expression
104
- end
105
-
106
- def computed?
107
- !computed_by.empty?
108
- end
109
-
110
- def computed_by
111
- [@binding_options[:computed_by]].flatten.compact
112
- end
113
-
114
- def nested_property_observers_for(observer)
115
- @nested_property_observers_collection ||= {}
116
- unless @nested_property_observers_collection.has_key?(observer)
117
- @nested_property_observers_collection[observer] = nested_property_names.reduce({}) do |output, property_name|
118
- output.merge(
119
- property_name => Observer.proc do |new_value|
120
- # Ensure reattaching observers when a higher level nested property is updated (e.g. person.address changes reattaches person.address.street observer)
121
- add_observer(observer)
122
- observer.call(evaluate_property)
123
- end
124
- )
125
- end
126
- end
127
- @nested_property_observers_collection[observer]
128
- end
129
-
130
- def add_observer(observer)
131
- if computed?
132
- add_computed_observers(observer)
133
- elsif nested_property?
134
- add_nested_observers(observer)
135
- else
136
- model_binding_observer = Observer.proc do |new_value|
137
- observer.call(evaluate_property)
138
- end
139
- observer_registration = model_binding_observer.observe(model, property_name)
140
- my_registration = observer.registration_for(self)
141
- observer.add_dependent(my_registration => observer_registration)
142
- end
143
- end
144
-
145
- def remove_observer(observer)
146
- if computed?
147
- @computed_model_bindings.each do |computed_model_binding|
148
- computed_observer_for(observer).unobserve(computed_model_binding)
149
- end
150
- @computed_observer_collection.delete(observer)
151
- elsif nested_property?
152
- nested_property_observers_for(observer).clear
153
- else
154
- observer.unobserve(model, property_name)
155
- end
156
- end
157
-
158
- def computed_observer_for(observer)
159
- @computed_observer_collection ||= {}
160
- unless @computed_observer_collection.has_key?(observer)
161
- @computed_observer_collection[observer] = Observer.proc do |new_value|
162
- observer.call(evaluate_property)
163
- end
164
- end
165
- @computed_observer_collection[observer]
166
- end
167
-
168
- def add_computed_observers(observer)
169
- @computed_model_bindings.each do |computed_model_binding|
170
- observer_registration = computed_observer_for(observer).observe(computed_model_binding)
171
- my_registration = observer.registration_for(self)
172
- observer.add_dependent(my_registration => observer_registration)
173
- end
174
- end
175
-
176
- def add_nested_observers(observer)
177
- nested_property_observers = nested_property_observers_for(observer)
178
- nested_models.zip(nested_property_names).each_with_index do |zip, i|
179
- model, property_name = zip
180
- nested_property_observer = nested_property_observers[property_name]
181
- previous_index = i - 1
182
- parent_model = previous_index.negative? ? self : nested_models[previous_index]
183
- parent_property_name = previous_index.negative? ? nil : nested_property_names[previous_index]
184
- parent_observer = previous_index.negative? ? observer : nested_property_observers[parent_property_name]
185
- parent_property_name = nil if parent_property_name.to_s.start_with?('[')
186
- unless model.nil?
187
- if property_indexed?(property_name)
188
- # TODO figure out a way to deal with this more uniformly
189
- observer_registration = nested_property_observer.observe(model)
190
- else
191
- observer_registration = nested_property_observer.observe(model, property_name)
192
- end
193
- parent_registration = parent_observer.registration_for(parent_model, parent_property_name)
194
- parent_observer.add_dependent(parent_registration => observer_registration)
195
- end
196
- end
197
- end
198
-
199
- def call(value)
200
- return if model.nil?
201
- converted_value = value
202
- invoke_property_writer(model, "#{property_name}=", converted_value) unless evaluate_property == converted_value
203
- end
204
-
205
- def evaluate_property
206
- value = nil
207
- value = invoke_property_reader(model, property_name) unless model.nil?
208
- convert_on_read(value)
209
- end
210
-
211
- def evaluate_options_property
212
- model.send(options_property_name) unless model.nil?
213
- end
214
-
215
- def options_property_name
216
- self.property_name + "_options"
217
- end
218
-
219
- def property_indexed?(property_expression)
220
- property_expression.to_s.start_with?('[')
221
- end
222
-
223
- def invoke_property_reader(object, property_expression)
224
- if property_indexed?(property_expression)
225
- property_method = '[]'
226
- property_argument = property_expression[1...-1]
227
- property_argument = property_argument.to_i if property_argument.match(/\d+/)
228
- object.send(property_method, property_argument)
229
- else
230
- object.send(property_expression)
231
- end
232
- end
233
-
234
- def invoke_property_writer(object, property_expression, value)
235
- return if @binding_options[:read_only]
236
- value = convert_on_write(value)
237
- if property_indexed?(property_expression)
238
- property_method = '[]='
239
- property_argument = property_expression[1...-2]
240
- property_argument = property_argument.to_i if property_argument.match(/\d+/)
241
- object.send(property_method, property_argument, value)
242
- else
243
- object.send(property_expression, value)
244
- end
245
- end
246
- end
247
- end
248
- end
@@ -1,21 +0,0 @@
1
- require 'glimmer/error'
2
-
3
- module Glimmer
4
- module DataBinding
5
- module Observable
6
- # TODO rename methods to observe/unobserve
7
- def add_observer(observer, property_or_properties=nil)
8
- raise Error, 'Not implemented!'
9
- end
10
-
11
- def remove_observer(observer, property_or_properties=nil)
12
- raise Error, 'Not implemented!'
13
- end
14
-
15
- # Overriding inspect to avoid printing very long observer hierarchies
16
- def inspect
17
- "#<#{self.class.name}:0x#{self.hash.to_s(16)}>"
18
- end
19
- end
20
- end
21
- end
@@ -1,107 +0,0 @@
1
- require 'set'
2
-
3
- require_relative 'observable'
4
-
5
- module Glimmer
6
- module DataBinding
7
- # TODO prefix utility methods with double-underscore
8
- module ObservableArray
9
- include Observable
10
-
11
- def add_observer(observer, element_properties=nil)
12
- return observer if has_observer?(observer) && element_properties.nil?
13
- property_observer_list << observer
14
- [element_properties].flatten.compact.each do |property|
15
- each do |element|
16
- observer.observe(element, property)
17
- end
18
- end
19
- observer
20
- end
21
-
22
- def remove_observer(observer, element_properties=nil)
23
- property_observer_list.delete(observer)
24
- [element_properties].flatten.compact.each do |property|
25
- each do |element|
26
- observer.unobserve(element, property)
27
- end
28
- end
29
- observer
30
- end
31
-
32
- def has_observer?(observer)
33
- property_observer_list.include?(observer)
34
- end
35
-
36
- def property_observer_list
37
- @property_observer_list ||= Set.new
38
- end
39
-
40
- def notify_observers
41
- property_observer_list.each {|observer| observer.call}
42
- end
43
-
44
- def self.extend_object(array)
45
- # TODO consider alias_method, and define_method instead
46
-
47
- array.instance_eval("alias __original_add <<")
48
- array.instance_eval <<-end_eval, __FILE__, __LINE__
49
- def <<(value)
50
- self.__original_add(value)
51
- notify_observers
52
- end
53
- end_eval
54
-
55
- array.instance_eval("alias __original_set_value []=")
56
- array.instance_eval <<-end_eval, __FILE__, __LINE__
57
- def []=(index, value)
58
- old_value = self[index]
59
- unregister_dependent_observers(old_value)
60
- self.__original_set_value(index, value)
61
- notify_observers
62
- end
63
- end_eval
64
-
65
- array.instance_eval("alias __original_delete delete")
66
- array.instance_eval <<-end_eval, __FILE__, __LINE__
67
- def delete(value)
68
- unregister_dependent_observers(value)
69
- self.__original_delete(value)
70
- notify_observers
71
- end
72
- end_eval
73
-
74
- array.instance_eval("alias __original_delete_at delete_at")
75
- array.instance_eval <<-end_eval, __FILE__, __LINE__
76
- def delete_at(index)
77
- old_value = self[index]
78
- unregister_dependent_observers(old_value)
79
- self.__original_delete_at(index)
80
- notify_observers
81
- end
82
- end_eval
83
-
84
- array.instance_eval("alias __original_clear clear")
85
- array.instance_eval <<-end_eval, __FILE__, __LINE__
86
- def clear
87
- each do |old_value|
88
- unregister_dependent_observers(old_value)
89
- end
90
- self.__original_clear
91
- notify_observers
92
- end
93
- end_eval
94
-
95
- super
96
- end
97
-
98
- def unregister_dependent_observers(old_value)
99
- # TODO look into optimizing this
100
- return unless old_value.is_a?(ObservableModel) || old_value.is_a?(ObservableArray)
101
- property_observer_list.each do |observer|
102
- observer.unregister_dependents_with_observable(observer.registration_for(self), old_value)
103
- end
104
- end
105
- end
106
- end
107
- end
@@ -1,108 +0,0 @@
1
- require 'glimmer'
2
-
3
- require_relative 'observable'
4
- require_relative 'observer'
5
-
6
- module Glimmer
7
- module DataBinding
8
- # TODO prefix utility methods with double-underscore
9
- module ObservableModel
10
- include Observable
11
-
12
- class Notifier
13
- include Observer
14
- def initialize(observable_model, property_name)
15
- @observable_model = observable_model
16
- @property_name = property_name
17
- end
18
- def call(new_value=nil)
19
- @observable_model.notify_observers(@property_name)
20
- end
21
- end
22
-
23
- def add_observer(observer, property_name)
24
- return observer if has_observer?(observer, property_name)
25
- property_observer_list(property_name) << observer
26
- add_property_writer_observers(property_name)
27
- observer
28
- end
29
-
30
- def remove_observer(observer, property_name)
31
- property_observer_list(property_name).delete(observer)
32
- end
33
-
34
- def has_observer?(observer, property_name)
35
- property_observer_list(property_name).include?(observer)
36
- end
37
-
38
- def has_observer_for_any_property?(observer)
39
- property_observer_hash.values.map(&:to_a).sum.include?(observer)
40
- end
41
-
42
- def property_observer_hash
43
- @property_observers ||= Hash.new
44
- end
45
-
46
- def property_observer_list(property_name)
47
- property_observer_hash[property_name.to_sym] = Set.new unless property_observer_hash[property_name.to_sym]
48
- property_observer_hash[property_name.to_sym]
49
- end
50
-
51
- def notify_observers(property_name)
52
- property_observer_list(property_name).each {|observer| observer.call(send(property_name))}
53
- end
54
- #TODO upon updating values, make sure dependent observers are cleared (not added as dependents here)
55
-
56
- def add_property_writer_observers(property_name)
57
- property_writer_name = "#{property_name}="
58
- method(property_writer_name)
59
- ensure_array_object_observer(property_name, send(property_name))
60
- begin
61
- method("__original_#{property_writer_name}")
62
- rescue
63
- # TODO consider alias_method or define_method instead
64
- instance_eval "alias __original_#{property_writer_name} #{property_writer_name}"
65
- instance_eval <<-end_eval, __FILE__, __LINE__
66
- def #{property_writer_name}(value)
67
- old_value = self.#{property_name}
68
- unregister_dependent_observers('#{property_name}', old_value)
69
- self.__original_#{property_writer_name}(value)
70
- notify_observers('#{property_name}')
71
- ensure_array_object_observer('#{property_name}', value, old_value)
72
- end
73
- end_eval
74
- end
75
- rescue => e
76
- # ignore writing if no property writer exists
77
- Glimmer::Config.logger&.debug "No need to observe property writer: #{property_writer_name}\n#{e.message}\n#{e.backtrace.join("\n")}"
78
- end
79
-
80
- def unregister_dependent_observers(property_name, old_value)
81
- # TODO look into optimizing this
82
- return unless old_value.is_a?(ObservableModel) || old_value.is_a?(ObservableArray)
83
- property_observer_list(property_name).each do |observer|
84
- observer.unregister_dependents_with_observable(observer.registration_for(self, property_name), old_value)
85
- end
86
- end
87
-
88
- def ensure_array_object_observer(property_name, object, old_object = nil)
89
- return unless object.is_a?(Array)
90
- array_object_observer = array_object_observer_for(property_name)
91
- array_observer_registration = array_object_observer.observe(object)
92
- property_observer_list(property_name).each do |observer|
93
- my_registration = observer.registration_for(self, property_name) # TODO eliminate repetition
94
- observer.add_dependent(my_registration => array_observer_registration)
95
- end
96
- array_object_observer_for(property_name).unregister(old_object) if old_object.is_a?(ObservableArray)
97
- end
98
-
99
- def array_object_observer_for(property_name)
100
- @array_object_observers ||= {}
101
- unless @array_object_observers.has_key?(property_name)
102
- @array_object_observers[property_name] = ObservableModel::Notifier.new(self, property_name)
103
- end
104
- @array_object_observers[property_name]
105
- end
106
- end
107
- end
108
- end