mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-22 22:06:50 +00:00
Namespace is included in auto-registered adapters [ci skip]
This commit is contained in:
parent
592a5db96e
commit
efdd466147
@ -122,7 +122,7 @@ If a symbol, then the adapter must be, e.g. `:great_example`,
|
||||
There are two ways to register an adapter:
|
||||
|
||||
1) The simplest, is to subclass `ActiveModel::Serializer::Adapter::Base`, e.g. the below will
|
||||
register the `Example::UsefulAdapter` as `:useful_adapter`.
|
||||
register the `Example::UsefulAdapter` as `"example/useful_adapter"`.
|
||||
|
||||
```ruby
|
||||
module Example
|
||||
@ -131,10 +131,10 @@ module Example
|
||||
end
|
||||
```
|
||||
|
||||
You'll notice that the name it registers is the class name underscored, not the full namespace.
|
||||
You'll notice that the name it registers is the underscored namespace and class.
|
||||
|
||||
Under the covers, when the `ActiveModel::Serializer::Adapter::Base` is subclassed, it registers
|
||||
the subclass as `register(:useful_adapter, Example::UsefulAdapter)`
|
||||
the subclass as `register("example/useful_adapter", Example::UsefulAdapter)`
|
||||
|
||||
2) Any class can be registered as an adapter by calling `register` directly on the
|
||||
`ActiveModel::Serializer::Adapter` class. e.g., the below registers `MyAdapter` as
|
||||
|
||||
Loading…
Reference in New Issue
Block a user