watir_model 0.5.6 → 0.5.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8b328fcad2cf878f819bc74cfe6326ff46236e58
4
- data.tar.gz: 21252c87efb0abc47d259dd9f39c6c26bb0819f0
3
+ metadata.gz: 63c72fa3e00ff53cdd963b221d32468fcde94183
4
+ data.tar.gz: bbc0be248072064c854e3aa6234f70897490c7b4
5
5
  SHA512:
6
- metadata.gz: 7294bb8d1f90fa63beffc18a0aeabab3ad22749e9923e968542f82b016c8b52fcccb959c57c924d2be01af530a0541cc26d4d2a42cab97318b6e8714c13d90b7
7
- data.tar.gz: 25f15ebe9babea61559b1092412d16d0b1a3d4935229845c01e025e6b3e12d822f9bc546d6e224547ecda200e3dc7e994b6c458c5f9bd81a931ce616f9bcdc8c
6
+ metadata.gz: 344b9591dda9ec985bcd865df39eb2bbff22863badbb7e3e8d3520d3abbaee62c4c603c6594135bd7c12179787552ee540448de1f51ada54e0d0b8afab96d983
7
+ data.tar.gz: bbbeb59b42e533dbb0885a187fa161fc3de6a75759c368d4a5329d21cdaef0d89e2d63a04f6ca521bfac5acafc8f3c652b102c2240d92f66e32faf22159103dc
data/CHANGES.md CHANGED
@@ -1,3 +1,7 @@
1
+ ### 0.5.7 (2018-01-21)
2
+
3
+ * support converting to and from custom data types
4
+
1
5
  ### 0.5.6 (2018-01-21)
2
6
 
3
7
  * fix bug with conversion of namespaced classes
@@ -1,40 +1,40 @@
1
1
  module DataConversions
2
2
 
3
- def convert_string(value)
3
+ def convert_to_string(value)
4
4
  value.to_s
5
5
  end
6
6
 
7
- def convert_time(value)
8
- Object.const_get(__callee__.to_s.gsub('convert_', '').camelcase).parse value
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 convert_integer(value)
14
+ def convert_to_integer(value)
15
15
  value.to_i
16
16
  end
17
17
 
18
- def convert_float(value)
18
+ def convert_to_float(value)
19
19
  value.to_f
20
20
  end
21
21
 
22
- def convert_boolean(value)
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 convert_symbol(value)
28
+ def convert_to_symbol(value)
29
29
  value.to_sym
30
30
  end
31
31
 
32
- def convert_hash(value)
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 convert_array(value)
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 = "convert_#{data_type.to_s.underscore.tr('/', '_')}"
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
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "watir_model"
5
- spec.version = "0.5.6"
5
+ spec.version = "0.5.7"
6
6
  spec.authors = ["Titus Fortner"]
7
7
  spec.email = ["titusfortner@gmail.com"]
8
8
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: watir_model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.6
4
+ version: 0.5.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Titus Fortner