panko_serializer 0.7.0 → 0.7.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
  SHA256:
3
- metadata.gz: c4f169a6a48bba339628ae84995ec2ee3bf66ef059e941be74a89dbe6ec4e983
4
- data.tar.gz: dff287d42fe253ef3647f0555e47be7fea55ecc2cf1025cb6b0e55a734ca7806
3
+ metadata.gz: da5e3519b69aef1b8ada75ae3a245b6eb760a4168aad14e732288b1deaffdf57
4
+ data.tar.gz: 55dfcbe193da0e64285ebe006f98ac414b29a3f1270e7ae503986e3281332fc7
5
5
  SHA512:
6
- metadata.gz: 6e7507ee84bf00be48b9a5e35c9f06aacf083216242925889e2f1f0dfb24d87ba1a3ddbdd77bbf580f3000c5671873344dd32e98eea77f84bf175b4cf7c746be
7
- data.tar.gz: 0cb0515ccd98c7f260f81d7e1ecb1f684d70d03609b849fd2141d4a4630946622cbc34a6ae1666f6ca5a226066f959280b08bde5ad81f6c02e7d59cf9da6f466
6
+ metadata.gz: e49c292a8ffa051e82333f3ec89865c5a50643a150a18a2f0b4755f3a0a0cc3fbfce33bf853a66a3deaed6972f0824d5bf5a52537ff0c1d03c4152fee04659f1
7
+ data.tar.gz: 7c9084df275f4a096a7f58c95e14304fde32824ae415dc21d1979fab9726884a4d75c2654d060aecebc033751df89a81185a8f044fa887f08812b45d089a5fc7
data/.travis.yml CHANGED
@@ -2,9 +2,9 @@ sudo: false
2
2
  cache: bundler
3
3
  language: ruby
4
4
  rvm:
5
- - 2.5.5
6
- - 2.6.3
7
- - 2.7.0-preview1
5
+ - 2.5.7
6
+ - 2.6.5
7
+ - 2.7.0-rc2
8
8
 
9
9
  env:
10
10
  global:
@@ -27,3 +27,8 @@ env:
27
27
  - "RAILS_VERSION=4.2.0"
28
28
  - "RAILS_VERSION=5.2.0"
29
29
  - "RAILS_VERSION=6.0.0"
30
+
31
+ jobs:
32
+ exclude:
33
+ - rvm: 2.7.0-rc2
34
+ - env: RAILS_VERSION=4.2.0
data/docs/associations.md CHANGED
@@ -13,7 +13,7 @@ class PostSerializer < Panko::Serializer
13
13
  end
14
14
  ```
15
15
 
16
- # Associations with aliases
16
+ ### Associations with aliases
17
17
 
18
18
  An association key name can be aliased with the `name` option.
19
19
 
data/docs/attributes.md CHANGED
@@ -9,11 +9,11 @@ There are two types of attributes:
9
9
 
10
10
  ```ruby
11
11
  class UserSerializer < Panko::Serializer
12
- attributes :full_name
13
-
14
- def full_name
15
- "#{object.first_name} #{object.last_name}"
16
- end
12
+ attributes :full_name
13
+
14
+ def full_name
15
+ "#{object.first_name} #{object.last_name}"
16
+ end
17
17
  end
18
18
  ```
19
19
 
@@ -32,9 +32,11 @@ The serializer's attribute methods can access the object being serialized as `ob
32
32
 
33
33
  ```ruby
34
34
  class PostSerializer < Panko::Serializer
35
- def author_name
36
- "#{object.author.first_name} #{object.author.last_name}"
37
- end
35
+ attributes :author_name
36
+
37
+ def author_name
38
+ "#{object.author.first_name} #{object.author.last_name}"
39
+ end
38
40
  end
39
41
  ```
40
42
 
@@ -78,9 +80,16 @@ UserSerializer.new(only: [:name]).serialize(User.first)
78
80
  UserSerializer.new(except: [:name]).serialize(User.first)
79
81
  ```
80
82
 
83
+ > **Note** that if you want to user filter on an associations, the `:name`
84
+ > property is not taken into account.
85
+ > If you have a `has_many :state_transitions, name: :history` association
86
+ > defined, the key to use in filters is `:state_transitions`
87
+ > (e.g. `{ except: [:state_statitions] }`)
88
+
81
89
  ## Filters For
82
90
 
83
- Sometimes you find yourself have the same filtering logic in actions in order to solve this duplication, Panko allows you to write the filters in the serializer.
91
+ Sometimes you find yourself have the same filtering logic in actions in order to
92
+ solve this duplication, Panko allows you to write the filters in the serializer.
84
93
 
85
94
  ```ruby
86
95
  class UserSerializer < Panko::Serializer
@@ -122,4 +131,3 @@ class PostSerializer < Panko::Serializer
122
131
  aliases created_at: :published_at
123
132
  end
124
133
  ```
125
-
@@ -31,6 +31,20 @@ class UserSerializer < Panko::Serializer
31
31
  end
32
32
  ```
33
33
 
34
+ ### Serializing an object
35
+
36
+ And now serialize a single object
37
+
38
+ ```ruby
39
+ # Using Oj serializer
40
+ PostSerializer.new.serialize_to_json(Post.first)
41
+
42
+ # or, similar to #serializable_hash
43
+ PostSerializer.new.serialize(Post.first).to_json
44
+ ```
45
+
46
+ ### Using the serializers in a controller
47
+
34
48
  As you can see, defining serializers is simple and resembles ActiveModelSerializers 0.9,
35
49
  To utilize the `UserSerializer` inside a Rails controller and serialize some users, all we need to do is:
36
50
 
@@ -44,4 +58,3 @@ end
44
58
  ```
45
59
 
46
60
  And voila, we have endpoint which serialize users using Panko!
47
-
data/lib/panko/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Panko
4
- VERSION = "0.7.0"
4
+ VERSION = "0.7.1"
5
5
  end
@@ -30,5 +30,5 @@ Gem::Specification.new do |spec|
30
30
 
31
31
  spec.extensions << "ext/panko_serializer/extconf.rb"
32
32
 
33
- spec.add_dependency "oj", "~> 3.9.0"
33
+ spec.add_dependency "oj", "~> 3.10.0"
34
34
  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.7.0
4
+ version: 0.7.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: 2019-08-26 00:00:00.000000000 Z
11
+ date: 2019-12-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oj
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 3.9.0
19
+ version: 3.10.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 3.9.0
26
+ version: 3.10.0
27
27
  description:
28
28
  email:
29
29
  - yosy101@gmail.com