served 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: d11074c7b90454aa81d91112e40193f02cdc10d9
4
- data.tar.gz: 8ff28aba99def1020f220eb3ba0267b9a011a74a
3
+ metadata.gz: 28bd83eaad8fbfaf3478b00a64f55943139c48b6
4
+ data.tar.gz: bd5cd09084d8cd7e478f23caf4809713e44452b3
5
5
  SHA512:
6
- metadata.gz: c5ab6656edc9a54d00b6e265c82591d66adf9ed619a44dab217c35257e12c0e7bc18350dd4178198aef66793326808a8daf52e711510334cd9307873b4984e3d
7
- data.tar.gz: 23218806f29bddd9ffb2ad09cf80e2a03098c92a09422e0e8aa4fafe3e385384612b3dfced08d80017527d0c4b7f06a530864c9e1d2e5ca83f9505213b26e89d
6
+ metadata.gz: 2fda6f88f5283580f637feaa43ed86c6a655584a22a2380054020f83ad1bef2cbeff9daf6e77f17230cb00b3adc176104a811da22e9a7cbd4f963ac49d98990e
7
+ data.tar.gz: 3b9598697f9ffcbf11a3e28ef565697254f814c565cd10a3d122cc95679a21aba8c9eb43783fc08a447760e6073dc4b804399318560d8d0a6a10360af2773afd
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.2
4
+ * fixes edge case where TrueClass is passed in intead of a string to a `Boolean` serialized attribute
5
+
6
+ ## 0.3.1
7
+ * fixes regression in error handling
8
+
3
9
  ## 0.3.0
4
10
  * Added Serializers feature, ability to define different methods of serializing resource response
5
11
  * New error handling, will report different errors based on response from resource
data/README.md CHANGED
@@ -33,7 +33,7 @@ Served models derive their hostname by mapping their parent module to the `Serve
33
33
  example, `SomeService::SomeResource` would look up its host configuration at
34
34
  `Served.config.hosts['some_service']`.
35
35
 
36
- The host configuration accepts an (Addressable)[https://github.com/sporkmonger/addressable] template mapping
36
+ The host configuration accepts an [Addressable](https://github.com/sporkmonger/addressable) template mapping
37
37
  `resource` as the resource name (derived from the model name) and `query` as the params. For example:
38
38
 
39
39
  ```
@@ -33,6 +33,7 @@ module Served
33
33
  end
34
34
 
35
35
  def from_hash(hash)
36
+ hash = hash.clone
36
37
  hash.each do |name, value|
37
38
  hash[name] = serialize_attribute(name, value)
38
39
  end
@@ -48,9 +49,10 @@ module Served
48
49
  return ->(v) { return v.try(:to_s) } if type == String
49
50
  return ->(v) { return v.try(:to_sym) } if type == Symbol
50
51
  return ->(v) { return v.try(:to_f) } if type == Float
52
+ return ->(v) { return v.try(:to_a) } if type == Array
51
53
  if type == Boolean
52
54
  return lambda do |v|
53
- return false unless v == "true"
55
+ return false unless v == "true" || v.is_a?(TrueClass)
54
56
  true
55
57
  end
56
58
  end
@@ -63,7 +65,8 @@ module Served
63
65
  return false unless attributes[attr.to_sym]
64
66
  serializer = attribute_serializer_for(attributes[attr.to_sym][:serialize])
65
67
  if value.is_a? Array
66
- return value unless attributes[attr.to_sym][:serialize]
68
+ # TODO: Remove the Array class check below in 1.0, only here for backwards compatibility
69
+ return value if attributes[attr.to_sym][:serialize].nil? || attributes[attr.to_sym][:serialize] == Array
67
70
  value.collect do |v|
68
71
  if v.is_a? attributes[attr.to_sym][:serialize]
69
72
  v
@@ -1,3 +1,3 @@
1
1
  module Served
2
- VERSION = '0.3.1'
2
+ VERSION = '0.3.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: served
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
  - Jarod Reid
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-06-08 00:00:00.000000000 Z
11
+ date: 2017-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -210,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
210
210
  version: '0'
211
211
  requirements: []
212
212
  rubyforge_project:
213
- rubygems_version: 2.6.8
213
+ rubygems_version: 2.6.12
214
214
  signing_key:
215
215
  specification_version: 4
216
216
  summary: Served provides an easy to use model layer for communicating with disributed