abc_jsonapi 0.2.1 → 0.2.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: a32de4446187395c51ca0c74337fce16277306c3720a1a3a1343cc7a931ea2eb
4
- data.tar.gz: d04e65627b5ebfbf07a179256e42468c159adc51a5956638b31a404274d5a745
3
+ metadata.gz: f930de70d9fa7967f92ce01a75603086b7c7452115c00960753c687add337dda
4
+ data.tar.gz: b807f6ce9a7247d9add59c128054f852c969293638f8e952c961cb57fbd71435
5
5
  SHA512:
6
- metadata.gz: 7d98ad8a97ee7dc9b5ec4cfae77b55be6cbafe06fe64e1cf69c39f0b46f2392c15e1683a412bd82594e9cd07019fddb700831c530c118a12b795ce3344a60adb
7
- data.tar.gz: cf1b1de98a118746bae5d939a83d524ac60cfd04b1a99423c8f84c6e5bb92ecd31f6339151d0fa4e0268c55e87c9b2a83e7e83b639138775a9bc3f29ec4141f2
6
+ metadata.gz: ff3689062fb7f110442e9a94ceeda3dd8755b4ea2f838db155d4e1752d97adb85b2f0cd9791193519642158148ac754b579c736da05cabfb46e9c2d811424ab2
7
+ data.tar.gz: 1eb4f4ff0c4b47d5c0682df1b5a917d687e0f7e172de4f1e91e40d5a9bc1ea2daef9764d2c1cdfe6e6811986857bb764270305d1fe22b09ea4523cb3fb78c053
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- abc_jsonapi (0.2.1)
4
+ abc_jsonapi (0.2.2)
5
5
  activesupport (>= 5.2)
6
6
  i18n
7
7
 
data/README.md CHANGED
@@ -1,7 +1,9 @@
1
1
  # AbcJsonapi
2
2
 
3
- Minimalistic gem for JSON Serialization according to https://jsonapi.org spec
3
+ Minimalistic gem for JSON Serialization according to https://jsonapi.org spec.
4
+
4
5
  Inspired by [https://github.com/Netflix/fast_jsonapi](https://github.com/Netflix/fast_jsonapi)
6
+
5
7
  Contributions are welcome.
6
8
 
7
9
  ## Installation
@@ -39,7 +41,7 @@ The serializer is able to work with any ruby ​​objects. Not only ActiveRecor
39
41
 
40
42
  ```ruby
41
43
  class Author
42
- attr_reader :first_name, :last_name, :public_name, :contact_id
44
+ attr_reader :first_name, :last_name, :public_name, :contact_id
43
45
  end
44
46
  ```
45
47
 
@@ -47,11 +49,11 @@ end
47
49
 
48
50
  ```ruby
49
51
  class AuthorSerializer
50
- include AbcJsonapi::Serializer
51
- resource_type :people (optional)
52
- attributes :first_name, :last_name, :public_name
53
- belongs_to :contact
54
- has_many :books
52
+ include AbcJsonapi::Serializer
53
+ resource_type :people (optional)
54
+ attributes :first_name, :last_name, :public_name
55
+ belongs_to :contact
56
+ has_many :books
55
57
  end
56
58
  ```
57
59
 
@@ -64,7 +66,7 @@ Default resource type of direct serializing model is taken from serializer filen
64
66
  Jsonapi attributes may be declared with class method of serializer - `attributes`:
65
67
 
66
68
  ```ruby
67
- attributes :first_attribute, :second, *other
69
+ attributes :first_attribute, :second, *other attributes*
68
70
  ```
69
71
 
70
72
  `attributes` arguments will be called on serializing model as methods.
@@ -73,7 +75,7 @@ Also there is `attribute` method to declare single property. You can pass a bloc
73
75
 
74
76
  ```ruby
75
77
  attribute :date_of_birth do |object|
76
- object.date_of_birth.strftime("%FT%T.%3N%:z") if object.stop.present?
78
+ object.date_of_birth.strftime("%FT%T.%3N%:z") if object.date_of_birth.present?
77
79
  end
78
80
  ```
79
81
 
@@ -113,9 +115,9 @@ AuthorSerializer.new(resource, options).serialized_json
113
115
 
114
116
  ```ruby
115
117
  AbcJsonapi.configure do |config|
116
- config.transform_keys = true
117
- config.key_transform_method = "camel"
118
- config.pluralize_resources = true
118
+ config.transform_keys = true
119
+ config.key_transform_method = "camel"
120
+ config.pluralize_resources = true
119
121
  end
120
122
  ```
121
123
 
@@ -27,8 +27,8 @@ module AbcJsonapi
27
27
  @resource_attributes = self.class.resource_attributes
28
28
  @relationships = self.class.relationships
29
29
  @virtual_attributes = self.class.virtual_attributes
30
- @includes = options[:include]
31
- @meta = options[:meta]
30
+ @includes = options[:include] if options[:include].present?
31
+ @meta = options[:meta] if options[:meta].present?
32
32
  end
33
33
 
34
34
  def serializable_hash
@@ -1,3 +1,3 @@
1
1
  module AbcJsonapi
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: abc_jsonapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zhmakin Evgeniy