grape_serializer 0.0.4 → 0.0.6

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: 365b93beb22378e48cce221591e78a43f2557cc96ffa33d83b9096684a05ed70
4
- data.tar.gz: dc0e5ac1bde06003e4117d45d3bb0dac9fec60cc9d75c27a4e496d48d0ed6938
3
+ metadata.gz: d31f1ee05cebcfd2d959a9123cf86c8e53efff1ca2e1a9c2cdac8e43c11eefcb
4
+ data.tar.gz: 0f65a85f1666d2530d1f756bec989c2f31ff9e6a02872e9d3af03c7c3302939e
5
5
  SHA512:
6
- metadata.gz: a8a7e266ba22102f6d4b01346a1276ac6c862645c6de5fe3e03f0f6d31953520c3421bc2f0417f9259be3837cb49fc761fd91d2179ce708254f239d03959de06
7
- data.tar.gz: 2d4ea395095beff07ede1b3f93e5a074388e0e6a3737465e5655f9e6446ef516fe3a1f2ee42220a390ffb07abd519225e07809de96af1d4d1e4baa47b130ac68
6
+ metadata.gz: 6c476bb7bfee44ee5d714fb6dde17152b1e863b5a13430f389f393b752c53fa915d469e053377b54afec553ff1bf72dab11406ae518088d0337c3f3120f1c2da
7
+ data.tar.gz: e527832ea4031f70bda355aab1bdb127628c76de9699e23a715f990505a5706c99c5d128704fdd339a552256705662e75c680896bbc09313a8e565e34d4ea890
@@ -16,7 +16,7 @@ class GrapeSerializer
16
16
  end
17
17
 
18
18
  def represent(resource, opts = {})
19
- preload_associations(resource) if defined?(::Rails::Engine) && defined?(::ActiveRecord) && resource.is_a?(ActiveRecord)
19
+ preload_associations(resource) if defined?(::Rails::Engine) && defined?(::ActiveRecord) && (resource.is_a?(ActiveRecord::Base) || resource.is_a?(ActiveRecord::Relation))
20
20
  self.class.entity_class.represent(resource, opts.merge(@params)).as_json
21
21
  end
22
22
 
@@ -2,6 +2,9 @@ require 'grape-entity'
2
2
 
3
3
  class ServiceEntity < Grape::Entity
4
4
 
5
+ # expose append info
6
+ expose :append_info, merge: true, if: :append
7
+
5
8
  # expose service additional info by default
6
9
  expose :service_info, merge: true, if: :service
7
10
 
@@ -12,4 +15,9 @@ class ServiceEntity < Grape::Entity
12
15
  service_name = service.class.name.underscore
13
16
  send(service_name) rescue nil || send(service_name.split('/').last) rescue {}
14
17
  end
18
+
19
+ def append_info
20
+ options[:append]
21
+ end
22
+
15
23
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grape_serializer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - JiaRou Lee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-03 00:00:00.000000000 Z
11
+ date: 2022-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: grape-entity