seri 0.1.1 → 0.1.2

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: 0cd689240bcf4de7c1e6e8e583a1a465c1d61102cb8d5aa26e99c50ddbe84399
4
- data.tar.gz: 69f82fa0bae7cd349713bf98f44454acb0fdd217491cf8cae9d07d0f1c4cceaf
3
+ metadata.gz: fc67e1a87dd3afa34adf64fad07ed97552b65c9c25764c83345e304cf439a889
4
+ data.tar.gz: cc76131744bc905f3444969c1e02b7ce82917c881855d730c9ac0f5493bc329b
5
5
  SHA512:
6
- metadata.gz: '010940cfb05b32b29af2ed9df5539832003cc829de76b9878844474f822d8499a47a16cb4798a74ec4f34a4455d3126c61cc66ac7b958f882489d4432da64287'
7
- data.tar.gz: 7d1311e5bc7712923a4acc852d95e3525ce63a28cb9319c3e792e64c2132bb00870045705b2702f32dbff1747e05d2eccccbf600a605aaf7c9f54b8384e08a2b
6
+ metadata.gz: c8fa1d5fe42fb81a3022cce31251816197e733f66bbf362d3cf2c7a0a1186da1cd53024846372f1d1039a4ba741773af6c3e038701beacc3bf76e57d0885ecb4
7
+ data.tar.gz: fc8707c87661070d53b7324b2a169337aa71fa024d1b362bd39de607885416b13ec6153109f7acba24f53ab6ad5851aa859c1f4d6ff0c7dca13c852f6f5af3f0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- seri (0.1.0)
4
+ seri (0.1.1)
5
5
  appsignal (~> 2.7)
6
6
  oj (~> 3.7)
7
7
 
@@ -1,3 +1,3 @@
1
1
  class Serializer
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
data/lib/serializer.rb CHANGED
@@ -4,6 +4,8 @@ require 'serializer/group_serializer'
4
4
  class Serializer
5
5
  class SerializerError < StandardError; end
6
6
 
7
+ ARRAYS = %w(Array ActiveRecord::AssociationRelation)
8
+
7
9
  Attribute = Struct.new(:key, :condition, :from, :serializer, :options)
8
10
 
9
11
  def self.attributes
@@ -62,7 +64,7 @@ class Serializer
62
64
  def serialize_value(value, serializer)
63
65
  return value unless serializer
64
66
 
65
- if value.is_a?(Array)
67
+ if ARRAYS.include?(value.class.to_s)
66
68
  value.map { |v| serializer.new(v).to_h }
67
69
  else
68
70
  serializer.new(value).to_h
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seri
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - grdw