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
 
@@ -1,3 +1,3 @@
1
1
  module CoercedAttrWriter
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coerced_attr_writer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: java
7
7
  authors: