panko_serializer 0.2.0 → 0.2.1

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: f657c0585ef9811fe8d9fcf0e2d1556869823b72
4
- data.tar.gz: 9e4cc917aabb38d3b803e0978fc312b5fe5696da
3
+ metadata.gz: 1f8c8098047862bf6d95374b0264acc9f4f7cf13
4
+ data.tar.gz: 7b09699d6414c86526771627dce82453fc47ff28
5
5
  SHA512:
6
- metadata.gz: bd44b3774e47cbd74a400c53040f41bc9edb7f58c1dc63a1e7c530827b2c878948bdfebe6c0250c59ea5af122ef281113f09402fd282e4f16aff5d883ca5df8f
7
- data.tar.gz: 3da4b8644375ed05481a7d9e00e27082ee5274eea06a60282395abe5aab06b90f0c17d4b525bcc4c44c08a5e48108f6cc725e9c6a6e85ee40c6c70b4f21e9102
6
+ metadata.gz: a07931e1d08b72cd15d575622c0daaaf557542c982ac2b1e8b60532e917dbdc59cb10074cda132a099199f506c715e286111534139be31ef1fe614eb8bda4ab9
7
+ data.tar.gz: fb14a45d3e797fb15c5e5a8ebfc46685d8ff03915a1c71d5d9a7354ab6a2380f4ee1d4f7e7bf51489c8b0d646a7b3b66443591884f6d76ccec44148f20a30dc5
@@ -40,6 +40,12 @@ module Panko
40
40
  attributes_only_filters, associations_only_filters = resolve_filters(options, :only)
41
41
  attributes_except_filters, associations_except_filters = resolve_filters(options, :except)
42
42
 
43
+ apply_aliases_filters(
44
+ self.aliases,
45
+ attributes_only_filters,
46
+ attributes_except_filters
47
+ )
48
+
43
49
  self.fields = apply_fields_filters(
44
50
  self.fields,
45
51
  attributes_only_filters,
@@ -133,5 +139,27 @@ module Panko
133
139
 
134
140
  fields
135
141
  end
142
+
143
+ def apply_aliases_filters(aliases, only, except)
144
+ return if self.aliases.nil? || self.aliases.empty?
145
+
146
+ unless only.empty?
147
+ only.map! do |field_name|
148
+ alias_name = self.aliases.key(field_name)
149
+ next field_name if alias_name.nil?
150
+
151
+ alias_name
152
+ end
153
+ end
154
+
155
+ unless except.empty?
156
+ except.map! do |field_name|
157
+ alias_name = self.aliases.key(field_name)
158
+ next field_name if alias_name.nil?
159
+
160
+ alias_name
161
+ end
162
+ end
163
+ end
136
164
  end
137
165
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Panko
3
- VERSION = "0.2.0"
3
+ VERSION = "0.2.1"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: panko_serializer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yosi Attias
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-21 00:00:00.000000000 Z
11
+ date: 2017-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler