coerced_attr_writer 0.0.2-java → 0.0.3-java
Sign up to get free protection for your applications and to get access to all the features.
@@ -15,11 +15,21 @@ class Class
|
|
15
15
|
|
16
16
|
set_#{attribute}(val)
|
17
17
|
end
|
18
|
-
|
19
|
-
def #{camel_writer_name}=(val)
|
20
|
-
#{attribute} = val
|
21
|
-
end
|
22
18
|
RUBY
|
19
|
+
|
20
|
+
# Do not want to overwrite the first with the second
|
21
|
+
# if this is a simple setter
|
22
|
+
unless "#{attribute}" == camel_writer_name
|
23
|
+
class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
24
|
+
def #{camel_writer_name}=(val)
|
25
|
+
unless val.is_a?(#{coercion_type})
|
26
|
+
val = val.to_java(#{coercion_type})
|
27
|
+
end
|
28
|
+
|
29
|
+
set_#{attribute}(val)
|
30
|
+
end
|
31
|
+
RUBY
|
32
|
+
end
|
23
33
|
end
|
24
34
|
end
|
25
35
|
|