fields-serializer 0.3.0 → 0.3.1

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: cda8e4765ff737edeef8212adfd6a26f6dd7b34a
4
- data.tar.gz: f7e82c6a454e90a08769d3fe7cfa4aea2c50bc3a
3
+ metadata.gz: 8e400a352bb3a82691a3a0e11f694611b7c0dd8e
4
+ data.tar.gz: 96a8af0bc2f59735656c6546525556c68cf74153
5
5
  SHA512:
6
- metadata.gz: e61f04ad8ab6300ad6f64b271bcead2c14c70782b8a784459d1d3689dd04d2265b76bfc9941e4b9a00e2e60b309052fb4fbb4e48e0aa97098d22d95832953f61
7
- data.tar.gz: 2c23058024f59904d56f3a9cd1fca0e19751cb52eb50999a2231196e69c95eafb302aa30908c9c62deb83dbc9623f964b5b3d8ac53bacabc26f5c6e8be49c5b2
6
+ metadata.gz: cf045e0197b430a1c5795286801ae966b9fc5199189780d36bf3a03b555c91ae0a9268b1629db2db3a678e8a0c9651aa51bc44b582977bcaeaf1b80a265017ad
7
+ data.tar.gz: 0c0915f5f3e81d2516252b9ee29e351e0b0d18f9afaad8c88d698604c7ee112d95120c4293b0659ae0a2b0055841cbfe1e572387d2d391702a41ba2d0192ac6c
@@ -26,15 +26,15 @@ class FieldSerializer < ActiveModel::Serializer
26
26
 
27
27
  def create_attribute_structure(attribute_stack, model)
28
28
  return model unless model.present?
29
- parent = attribute_stack.shift
30
- if attribute_stack.count > 0
31
- if model.kind_of?(Array)
32
- collection_attribute_structure(model, attribute_stack, parent)
29
+ if model.kind_of?(ActiveRecord::Relation)
30
+ collection_attribute_structure(model, attribute_stack)
31
+ else
32
+ parent = attribute_stack.first
33
+ if attribute_stack.count > 1
34
+ attribute_structure(model, attribute_stack[1..-1], parent)
33
35
  else
34
- attribute_structure(model, attribute_stack, parent)
36
+ value_structure(model, parent)
35
37
  end
36
- else
37
- value_structure(model, parent)
38
38
  end
39
39
  end
40
40
 
@@ -42,8 +42,8 @@ class FieldSerializer < ActiveModel::Serializer
42
42
  { parent => create_attribute_structure(attribute_stack, model.send(parent)) }
43
43
  end
44
44
 
45
- def collection_attribute_structure(models, attribute_stack, parent)
46
- models.map { |model| attribute_structure(model, attribute_stack, parent) }
45
+ def collection_attribute_structure(models, attribute_stack)
46
+ models.map { |model| create_attribute_structure(attribute_stack, model) }.compact
47
47
  end
48
48
 
49
49
  def merging_attributes(&block)
@@ -1,5 +1,5 @@
1
1
  module Fields
2
2
  module Serializer
3
- VERSION = "0.3.0"
3
+ VERSION = "0.3.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fields-serializer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stuart Chinery