restpack_serializer 0.4.24 → 0.4.25

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f41191ba4961b7f1ce4651b4fd1f510b9e784ff9
4
- data.tar.gz: b07c073cbccfa5964092ad108350f25aea0d1e26
3
+ metadata.gz: 7d870c817c227fbac2102919ec10f69e727b61d4
4
+ data.tar.gz: 14b4250d2a77c3d60b9e5c8872150b54503ff1f2
5
5
  SHA512:
6
- metadata.gz: f7c256addcf1c9212a02f2aeab7aca61a0f66b2e5ad0bd1ad9e5acebc59397359be5825d86dca3915ee087985f135a9d2bc5153889eb1496555468eb2f08b494
7
- data.tar.gz: 2435d8486616017591fb7f6041e39e6f66c69f06645822252da5eddd87b24c48cef73eb7118913c4761891be414de20dbb797914b8a2c4db69847e5e7da2e592
6
+ metadata.gz: 69e3fc5bc5c44d9c29ed24df5a06a326264e350d8147b9956ea1181546fdef97996145f0c3a7aabb081b5033129ca3e6ca3536ceca7d31c44e01b36c06ab49bb
7
+ data.tar.gz: fe92f589efcf2273642b1c88d13415d9e75034d79e0eb50c993841a0c9aa6c8689b06a8b474cc1080df6dc69b5931b9a556460f53b2ae1add05e1c947d90d7f6
@@ -0,0 +1,20 @@
1
+ class Symbolizer
2
+ def self.recursive_symbolize(hash)
3
+ {}.tap do |h|
4
+ hash.each { |key, value| h[key.to_sym] = self.map_value(value) }
5
+ end
6
+ end
7
+
8
+ private
9
+
10
+ def self.map_value(thing)
11
+ case thing
12
+ when Hash
13
+ self.recursive_symbolize(thing)
14
+ when Array
15
+ thing.map { |v| map_value(v) }
16
+ else
17
+ thing
18
+ end
19
+ end
20
+ end
@@ -6,6 +6,7 @@ require_relative "serializable/paging"
6
6
  require_relative "serializable/resource"
7
7
  require_relative "serializable/single"
8
8
  require_relative "serializable/side_loading"
9
+ require_relative "serializable/symbolizer"
9
10
 
10
11
  module RestPack
11
12
  module Serializer
@@ -46,7 +47,7 @@ module RestPack
46
47
  add_custom_attributes(data)
47
48
  add_links(model, data)
48
49
 
49
- data
50
+ Symbolizer.recursive_symbolize(data)
50
51
  end
51
52
 
52
53
  def custom_attributes
@@ -1,5 +1,5 @@
1
1
  module RestPack
2
2
  module Serializer
3
- VERSION = '0.4.24'
3
+ VERSION = '0.4.25'
4
4
  end
5
5
  end
@@ -24,7 +24,6 @@ Gem::Specification.new do |gem|
24
24
 
25
25
  gem.add_development_dependency 'restpack_gem', '~> 0.0.9'
26
26
  gem.add_development_dependency 'rake', '~> 10.0.3'
27
- gem.add_development_dependency 'rspec', '~> 2.12'
28
27
  gem.add_development_dependency 'guard-rspec', '~> 2.5.4'
29
28
  gem.add_development_dependency 'growl', '~> 1.0.3'
30
29
  gem.add_development_dependency 'factory_girl', '~> 4.2.0'
@@ -36,7 +36,12 @@ describe RestPack::Serializer do
36
36
  end
37
37
 
38
38
  def admin_info
39
- { key: "super_secret_sauce" }
39
+ {
40
+ "key" => "super_secret_sauce",
41
+ "array" => [
42
+ { "name" => "Alex" }
43
+ ]
44
+ }
40
45
  end
41
46
 
42
47
  def include_admin_info?
@@ -120,7 +125,12 @@ describe RestPack::Serializer do
120
125
 
121
126
  it "includes custom attributes if specified" do
122
127
  hash = serializer.as_json(person, { is_admin?: true })
123
- hash[:admin_info].should == { key: "super_secret_sauce" }
128
+ hash[:admin_info].should == {
129
+ key: "super_secret_sauce",
130
+ array: [
131
+ name: 'Alex'
132
+ ]
133
+ }
124
134
  end
125
135
  end
126
136
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: restpack_serializer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.24
4
+ version: 0.4.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gavin Joyce
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-19 00:00:00.000000000 Z
11
+ date: 2014-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -106,20 +106,6 @@ dependencies:
106
106
  - - "~>"
107
107
  - !ruby/object:Gem::Version
108
108
  version: 10.0.3
109
- - !ruby/object:Gem::Dependency
110
- name: rspec
111
- requirement: !ruby/object:Gem::Requirement
112
- requirements:
113
- - - "~>"
114
- - !ruby/object:Gem::Version
115
- version: '2.12'
116
- type: :development
117
- prerelease: false
118
- version_requirements: !ruby/object:Gem::Requirement
119
- requirements:
120
- - - "~>"
121
- - !ruby/object:Gem::Version
122
- version: '2.12'
123
109
  - !ruby/object:Gem::Dependency
124
110
  name: guard-rspec
125
111
  requirement: !ruby/object:Gem::Requirement
@@ -245,6 +231,7 @@ files:
245
231
  - lib/restpack_serializer/serializable/resource.rb
246
232
  - lib/restpack_serializer/serializable/side_loading.rb
247
233
  - lib/restpack_serializer/serializable/single.rb
234
+ - lib/restpack_serializer/serializable/symbolizer.rb
248
235
  - lib/restpack_serializer/version.rb
249
236
  - restpack_serializer.gemspec
250
237
  - spec/factory/factory_spec.rb
@@ -283,7 +270,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
283
270
  version: '0'
284
271
  requirements: []
285
272
  rubyforge_project:
286
- rubygems_version: 2.0.14
273
+ rubygems_version: 2.2.2
287
274
  signing_key:
288
275
  specification_version: 4
289
276
  summary: Model serialization, paging, side-loading and filtering