ibm-watson-ruby 0.3.1 → 0.3.2

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: bdf8b064072743cb9ddf55d1f9626f79c0e385bb
4
- data.tar.gz: 77d59632b67127be88bddbf2367e72160fcd967f
3
+ metadata.gz: 8816935104d171cac3690226adbc898c6e5bee37
4
+ data.tar.gz: 7006f6ed51a19c3838e3323861b248061b0a8ae2
5
5
  SHA512:
6
- metadata.gz: ccd633248fb735841fcb7a3c80eff71a872732acad8d89e63a7add5b6173cc6282a326dead20c089b42fc1b02e92e1ee11a6b09654abdf7e039c4fc876716270
7
- data.tar.gz: caa8c4547bbcca533320dd4541f1c74ac6a7a1d41f0a5dc453377b8fe1cd4311af4f961cbc9569bb201eefc16ce8b8f1ae9fa8734b8808c59c9b28e90981c22a
6
+ metadata.gz: 84da496aea39f5e34f371c9bf1e4aa921d2e7df4fd08cd9d7eda39dc425f90371cd8a6e872b4da9133f55db771d4f5437968db6374f6db77f015adcc2a477e7e
7
+ data.tar.gz: 32a60709486d783d86a85a040aa99dd5172c4f796c057543739531a7b66c17b2930cdbff00efe273fd2529b4c2dcf5d38b91635738ec16cff3380495527032e7
@@ -5,6 +5,8 @@ module IBMWatson
5
5
 
6
6
  # Support "Collection" attributes, eg:
7
7
  # attribute :foo, type: [String]
8
+ # also support Hash attributes
9
+ # attribute :foo, type: Hash
8
10
  def typecaster_for(type)
9
11
  if type.kind_of?(Array) && type.length == 1 && type.first.is_a?(Class)
10
12
  item_type = type.first
@@ -16,6 +18,14 @@ module IBMWatson
16
18
  item
17
19
  }
18
20
  end
21
+ elsif type == Hash
22
+ lambda do |value|
23
+ if value.kind_of?(String)
24
+ JSON.parse(value) || {}
25
+ else
26
+ value || {}
27
+ end
28
+ end
19
29
  else
20
30
  super
21
31
  end
@@ -1,3 +1,3 @@
1
1
  module IBMWatson
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ibm-watson-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bram Whillock