watir_model 0.5.6 → 0.5.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +4 -0
- data/lib/data_conversions.rb +9 -9
- data/lib/watir_model.rb +3 -1
- data/watir_model.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63c72fa3e00ff53cdd963b221d32468fcde94183
|
4
|
+
data.tar.gz: bbc0be248072064c854e3aa6234f70897490c7b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 344b9591dda9ec985bcd865df39eb2bbff22863badbb7e3e8d3520d3abbaee62c4c603c6594135bd7c12179787552ee540448de1f51ada54e0d0b8afab96d983
|
7
|
+
data.tar.gz: bbbeb59b42e533dbb0885a187fa161fc3de6a75759c368d4a5329d21cdaef0d89e2d63a04f6ca521bfac5acafc8f3c652b102c2240d92f66e32faf22159103dc
|
data/CHANGES.md
CHANGED
data/lib/data_conversions.rb
CHANGED
@@ -1,40 +1,40 @@
|
|
1
1
|
module DataConversions
|
2
2
|
|
3
|
-
def
|
3
|
+
def convert_to_string(value)
|
4
4
|
value.to_s
|
5
5
|
end
|
6
6
|
|
7
|
-
def
|
8
|
-
Object.const_get(__callee__.to_s.gsub('
|
7
|
+
def convert_to_time(value)
|
8
|
+
Object.const_get(__callee__.to_s.gsub('convert_to_', '').camelcase).parse value
|
9
9
|
end
|
10
10
|
|
11
11
|
alias_method :convert_date, :convert_time
|
12
12
|
alias_method :convert_date_time, :convert_time
|
13
13
|
|
14
|
-
def
|
14
|
+
def convert_to_integer(value)
|
15
15
|
value.to_i
|
16
16
|
end
|
17
17
|
|
18
|
-
def
|
18
|
+
def convert_to_float(value)
|
19
19
|
value.to_f
|
20
20
|
end
|
21
21
|
|
22
|
-
def
|
22
|
+
def convert_to_boolean(value)
|
23
23
|
return value if value.is_a?(TrueClass) || value.is_a?(FalseClass)
|
24
24
|
value = eval(value)
|
25
25
|
value.is_a?(TrueClass) || value.is_a?(FalseClass) ? value : nil
|
26
26
|
end
|
27
27
|
|
28
|
-
def
|
28
|
+
def convert_to_symbol(value)
|
29
29
|
value.to_sym
|
30
30
|
end
|
31
31
|
|
32
|
-
def
|
32
|
+
def convert_to_hash(value)
|
33
33
|
value = parse_json(value)
|
34
34
|
value.to_h if value.respond_to? :to_h
|
35
35
|
end
|
36
36
|
|
37
|
-
def
|
37
|
+
def convert_to_array(value)
|
38
38
|
value = parse_json(value)
|
39
39
|
value.is_a?(Array) ? value : Array(value)
|
40
40
|
end
|
data/lib/watir_model.rb
CHANGED
@@ -54,7 +54,7 @@ class WatirModel
|
|
54
54
|
data_type = data_types[key]
|
55
55
|
return value if data_type.nil?
|
56
56
|
return value if data_type.is_a?(Class) && value.is_a?(data_type)
|
57
|
-
method = "
|
57
|
+
method = "convert_to_#{data_type.to_s.underscore.tr('/', '_')}"
|
58
58
|
value = if respond_to? method
|
59
59
|
send(method, value)
|
60
60
|
else
|
@@ -168,6 +168,8 @@ class WatirModel
|
|
168
168
|
opt.each_with_object({}) do |key, hash|
|
169
169
|
value = send(key)
|
170
170
|
next if value.nil?
|
171
|
+
method = "convert_from_#{value.class.to_s.underscore.tr('/', '_')}"
|
172
|
+
value = send(method, value) if respond_to?(method)
|
171
173
|
value = value.to_h if value.is_a? WatirModel
|
172
174
|
hash[key] = value
|
173
175
|
end
|
data/watir_model.gemspec
CHANGED