glimmer-dsl-swt 0.1.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +31 -8
- data/RUBY_VERSION +1 -1
- data/VERSION +1 -1
- data/icons/scaffold_app.icns +0 -0
- data/lib/ext/glimmer.rb +8 -1
- data/lib/ext/glimmer/config.rb +12 -4
- data/lib/glimmer-dsl-swt.rb +8 -3
- data/lib/glimmer/data_binding/list_selection_binding.rb +0 -1
- data/lib/glimmer/data_binding/table_items_binding.rb +5 -4
- data/lib/glimmer/data_binding/widget_binding.rb +7 -6
- data/lib/glimmer/dsl/swt/combo_selection_data_binding_expression.rb +4 -0
- data/lib/glimmer/dsl/swt/dnd_expression.rb +25 -0
- data/lib/glimmer/dsl/swt/message_box_expression.rb +0 -4
- data/lib/glimmer/package.rb +2 -0
- data/lib/glimmer/rake_task.rb +22 -0
- data/lib/glimmer/rake_task/list.rb +73 -0
- data/lib/glimmer/scaffold.rb +3 -1
- data/lib/glimmer/swt/dnd_proxy.rb +34 -0
- data/lib/glimmer/swt/packages.rb +9 -6
- data/lib/glimmer/swt/style_constantizable.rb +120 -0
- data/lib/glimmer/swt/swt_proxy.rb +20 -88
- data/lib/glimmer/swt/table_proxy.rb +34 -11
- data/lib/glimmer/swt/widget_proxy.rb +147 -13
- metadata +72 -11
- data/lib/glimmer/data_binding/model_binding.rb +0 -248
- data/lib/glimmer/data_binding/observable.rb +0 -21
- data/lib/glimmer/data_binding/observable_array.rb +0 -107
- data/lib/glimmer/data_binding/observable_model.rb +0 -108
- data/lib/glimmer/data_binding/observer.rb +0 -124
metadata
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glimmer-dsl-swt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AndyMaleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
15
15
|
requirements:
|
16
16
|
- - "~>"
|
17
17
|
- !ruby/object:Gem::Version
|
18
|
-
version: 0.9.
|
18
|
+
version: 0.9.3
|
19
19
|
name: glimmer
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
@@ -23,7 +23,7 @@ dependencies:
|
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.9.
|
26
|
+
version: 0.9.3
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
29
29
|
requirements:
|
@@ -57,7 +57,7 @@ dependencies:
|
|
57
57
|
requirements:
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: 0.8.
|
60
|
+
version: 0.8.2
|
61
61
|
name: puts_debuggerer
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
@@ -65,7 +65,27 @@ dependencies:
|
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.8.
|
68
|
+
version: 0.8.2
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 1.2.4
|
75
|
+
- - "<"
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 2.0.0
|
78
|
+
name: text-table
|
79
|
+
type: :runtime
|
80
|
+
prerelease: false
|
81
|
+
version_requirements: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 1.2.4
|
86
|
+
- - "<"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 2.0.0
|
69
89
|
- !ruby/object:Gem::Dependency
|
70
90
|
requirement: !ruby/object:Gem::Requirement
|
71
91
|
requirements:
|
@@ -194,6 +214,48 @@ dependencies:
|
|
194
214
|
- - "~>"
|
195
215
|
- !ruby/object:Gem::Version
|
196
216
|
version: 3.5.0
|
217
|
+
- !ruby/object:Gem::Dependency
|
218
|
+
requirement: !ruby/object:Gem::Requirement
|
219
|
+
requirements:
|
220
|
+
- - '='
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
version: 0.8.23
|
223
|
+
name: coveralls
|
224
|
+
type: :development
|
225
|
+
prerelease: false
|
226
|
+
version_requirements: !ruby/object:Gem::Requirement
|
227
|
+
requirements:
|
228
|
+
- - '='
|
229
|
+
- !ruby/object:Gem::Version
|
230
|
+
version: 0.8.23
|
231
|
+
- !ruby/object:Gem::Dependency
|
232
|
+
requirement: !ruby/object:Gem::Requirement
|
233
|
+
requirements:
|
234
|
+
- - "~>"
|
235
|
+
- !ruby/object:Gem::Version
|
236
|
+
version: 0.16.1
|
237
|
+
name: simplecov
|
238
|
+
type: :development
|
239
|
+
prerelease: false
|
240
|
+
version_requirements: !ruby/object:Gem::Requirement
|
241
|
+
requirements:
|
242
|
+
- - "~>"
|
243
|
+
- !ruby/object:Gem::Version
|
244
|
+
version: 0.16.1
|
245
|
+
- !ruby/object:Gem::Dependency
|
246
|
+
requirement: !ruby/object:Gem::Requirement
|
247
|
+
requirements:
|
248
|
+
- - "~>"
|
249
|
+
- !ruby/object:Gem::Version
|
250
|
+
version: 0.7.0
|
251
|
+
name: simplecov-lcov
|
252
|
+
type: :development
|
253
|
+
prerelease: false
|
254
|
+
version_requirements: !ruby/object:Gem::Requirement
|
255
|
+
requirements:
|
256
|
+
- - "~>"
|
257
|
+
- !ruby/object:Gem::Version
|
258
|
+
version: 0.7.0
|
197
259
|
description: Glimmer DSL for SWT (Desktop GUI)
|
198
260
|
email: andy.am@gmail.com
|
199
261
|
executables:
|
@@ -216,12 +278,7 @@ files:
|
|
216
278
|
- lib/ext/glimmer/config.rb
|
217
279
|
- lib/glimmer-dsl-swt.rb
|
218
280
|
- lib/glimmer/data_binding/list_selection_binding.rb
|
219
|
-
- lib/glimmer/data_binding/model_binding.rb
|
220
|
-
- lib/glimmer/data_binding/observable.rb
|
221
|
-
- lib/glimmer/data_binding/observable_array.rb
|
222
|
-
- lib/glimmer/data_binding/observable_model.rb
|
223
281
|
- lib/glimmer/data_binding/observable_widget.rb
|
224
|
-
- lib/glimmer/data_binding/observer.rb
|
225
282
|
- lib/glimmer/data_binding/shine.rb
|
226
283
|
- lib/glimmer/data_binding/table_items_binding.rb
|
227
284
|
- lib/glimmer/data_binding/tree_items_binding.rb
|
@@ -235,6 +292,7 @@ files:
|
|
235
292
|
- lib/glimmer/dsl/swt/data_binding_expression.rb
|
236
293
|
- lib/glimmer/dsl/swt/dialog_expression.rb
|
237
294
|
- lib/glimmer/dsl/swt/display_expression.rb
|
295
|
+
- lib/glimmer/dsl/swt/dnd_expression.rb
|
238
296
|
- lib/glimmer/dsl/swt/dsl.rb
|
239
297
|
- lib/glimmer/dsl/swt/exec_expression.rb
|
240
298
|
- lib/glimmer/dsl/swt/layout_data_expression.rb
|
@@ -259,9 +317,11 @@ files:
|
|
259
317
|
- lib/glimmer/launcher.rb
|
260
318
|
- lib/glimmer/package.rb
|
261
319
|
- lib/glimmer/rake_task.rb
|
320
|
+
- lib/glimmer/rake_task/list.rb
|
262
321
|
- lib/glimmer/scaffold.rb
|
263
322
|
- lib/glimmer/swt/color_proxy.rb
|
264
323
|
- lib/glimmer/swt/display_proxy.rb
|
324
|
+
- lib/glimmer/swt/dnd_proxy.rb
|
265
325
|
- lib/glimmer/swt/font_proxy.rb
|
266
326
|
- lib/glimmer/swt/layout_data_proxy.rb
|
267
327
|
- lib/glimmer/swt/layout_proxy.rb
|
@@ -269,6 +329,7 @@ files:
|
|
269
329
|
- lib/glimmer/swt/message_box_proxy.rb
|
270
330
|
- lib/glimmer/swt/packages.rb
|
271
331
|
- lib/glimmer/swt/shell_proxy.rb
|
332
|
+
- lib/glimmer/swt/style_constantizable.rb
|
272
333
|
- lib/glimmer/swt/swt_proxy.rb
|
273
334
|
- lib/glimmer/swt/tab_item_proxy.rb
|
274
335
|
- lib/glimmer/swt/table_proxy.rb
|
@@ -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
|