light_serializer 0.0.7 → 0.0.8

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
  SHA256:
3
- metadata.gz: 25bb1a6af47fb69f5eabb3aaba9b52c2323751b86c3abd229c20935320f06c2c
4
- data.tar.gz: 57b67a1e1d29806e0028c6f9b7ad069b99ba57253e99adcef249dd292b1cf633
3
+ metadata.gz: e19a7ae11ca3bfee4350cad7874ba08e2f07a01031886c51585dda15538b9963
4
+ data.tar.gz: 38e370df48a4f0ec77b627038320f045425a761c2dceb3021a032eadd387a402
5
5
  SHA512:
6
- metadata.gz: 6c6f7a76a1e8c6f618547a9d0dbbc6e0a475ae2d009b0122b4b32de9572b378c6ebd61ee1dc41ddb74e0eed27be1afa1644f584cbd5a46c7959f95dbbd8a9925
7
- data.tar.gz: f3e6c53d11d2495711506281626c037f7870d061115cbafcb0f9b6741969dd9f4ef0615c8f310a0751ff65cd4c42342f0f1ad9e9cb3b5d6d92a1119dea1d34a3
6
+ metadata.gz: 172a24e89701dbb0d0784ef48aed9e3565f11184abdf8f70bfa0a0bbdf605df822593bf7da179995988159fb42d53ba3ae431c0deea071add5b675edfd843962
7
+ data.tar.gz: f5c0dc2b82b75a95a547061d59e3682eb96828704a252a1f844c25b5ca3a29cc12de99f7e63621bef67e2d04fb91b2bf81c622cc85bbd54505193036bfd3c0a9
data/.reek.yml CHANGED
@@ -8,3 +8,5 @@ detectors:
8
8
 
9
9
  exclude_paths:
10
10
  - vendor
11
+ - ./bench.rb
12
+
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- light_serializer (0.0.6)
4
+ light_serializer (0.0.8)
5
5
  oj (~> 3)
6
6
 
7
7
  GEM
@@ -37,9 +37,9 @@ GEM
37
37
  kwalify (0.7.2)
38
38
  method_source (0.9.0)
39
39
  minitest (5.11.3)
40
- oj (3.7.1)
40
+ oj (3.7.4)
41
41
  parallel (1.12.1)
42
- parser (2.5.1.2)
42
+ parser (2.5.3.0)
43
43
  ast (~> 2.4.0)
44
44
  powerpack (0.1.2)
45
45
  pry (0.11.3)
@@ -50,7 +50,7 @@ GEM
50
50
  pry (~> 0.10)
51
51
  rainbow (3.0.0)
52
52
  rake (10.5.0)
53
- reek (5.1.0)
53
+ reek (5.2.0)
54
54
  codeclimate-engine-rb (~> 0.4.0)
55
55
  kwalify (~> 0.7.0)
56
56
  parser (>= 2.5.0.0, < 2.6, != 2.5.1.1)
data/bench.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
2
4
  require 'bundler/inline'
3
5
 
@@ -297,3 +299,4 @@ benchmark_collection(ams_arg: '(without logging)', oj_arg: '(with Oj)')
297
299
  # Associations
298
300
  benchmark_associations_instance
299
301
  benchmark_associations_collection
302
+ # rubocop:enable Metrics/AbcSize,Metrics/MethodLength
@@ -54,7 +54,7 @@ module LightSerializer
54
54
  end
55
55
 
56
56
  def active_record_relation?(object)
57
- !!(defined?(ActiveRecord::Relation) && object.is_a?(ActiveRecord::Relation))
57
+ defined?(ActiveRecord::Relation) && object.is_a?(ActiveRecord::Relation)
58
58
  end
59
59
 
60
60
  def hashed_entity(entity, nested_serializer)
@@ -71,6 +71,7 @@ module LightSerializer
71
71
  end
72
72
  end
73
73
 
74
+ # :reek:ManualDispatch
74
75
  def obtain_value(object, attribute)
75
76
  if serializer.respond_to?(attribute)
76
77
  serializer.public_send(attribute)
@@ -3,8 +3,9 @@
3
3
  module LightSerializer
4
4
  module Helpers
5
5
  module WithCustomRoot
6
+ # :reek:UtilityFunction
6
7
  def with_custom_root(root)
7
- root ? { root.to_sym => yield } : yield
8
+ root ? { root.to_s => yield } : yield
8
9
  end
9
10
  end
10
11
  end
@@ -14,7 +14,7 @@ module LightSerializer
14
14
  end
15
15
 
16
16
  def to_json
17
- with_custom_root(root) { Oj.dump(hashed_collection, mode: :compat) }
17
+ Oj.dump(collection_with_root, mode: :compat)
18
18
  end
19
19
 
20
20
  def to_hash
@@ -23,6 +23,10 @@ module LightSerializer
23
23
 
24
24
  private
25
25
 
26
+ def collection_with_root
27
+ with_custom_root(root) { hashed_collection }
28
+ end
29
+
26
30
  def hashed_collection
27
31
  collection.map { |entity| serializer.new(entity, context: context).to_hash }
28
32
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # :reek:TooManyInstanceVariables { max_instance_variables: 5 }
3
4
  module LightSerializer
4
5
  class Serializer
5
6
  attr_reader :object, :root, :context, :meta
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LightSerializer
4
- VERSION = '0.0.7'
4
+ VERSION = '0.0.8'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: light_serializer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Rodionov
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-11-30 00:00:00.000000000 Z
12
+ date: 2018-12-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: oj