mirror of
https://github.com/samsonjs/grape-active_model_serializers.git
synced 2026-04-27 14:57:43 +00:00
Remove disabling inferrence as it is no longer handled by us
This commit is contained in:
parent
c599c489c3
commit
ea019c721e
2 changed files with 1 additions and 11 deletions
|
|
@ -55,13 +55,6 @@ end
|
||||||
```
|
```
|
||||||
In this case, as User objects are being returned, grape-active_model_serializers will look for a serializer named UserSerializer.
|
In this case, as User objects are being returned, grape-active_model_serializers will look for a serializer named UserSerializer.
|
||||||
|
|
||||||
### Disabling serializer inferrence
|
|
||||||
|
|
||||||
You can turn off serializer inferrence.
|
|
||||||
```ruby
|
|
||||||
Grape::Formatter::ActiveModelSerializers.infer_serializers = false
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
### Manually specifying serializer options
|
### Manually specifying serializer options
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,10 @@ module Grape
|
||||||
module Formatter
|
module Formatter
|
||||||
module ActiveModelSerializers
|
module ActiveModelSerializers
|
||||||
class << self
|
class << self
|
||||||
attr_accessor :infer_serializers
|
|
||||||
attr_reader :endpoint
|
attr_reader :endpoint
|
||||||
|
|
||||||
ActiveModelSerializers.infer_serializers = true
|
|
||||||
|
|
||||||
def call(resource, env)
|
def call(resource, env)
|
||||||
@endpoint = env["api.endpoint"]
|
@endpoint = env['api.endpoint']
|
||||||
options = endpoint.namespace_options.merge(endpoint.route_options)
|
options = endpoint.namespace_options.merge(endpoint.route_options)
|
||||||
|
|
||||||
if resource.respond_to?(:to_ary) && !resource.empty?
|
if resource.respond_to?(:to_ary) && !resource.empty?
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue