forked from runtastic/active_model_serializers
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- The removed classes and modules were added back with deprecation warning and deprecation test were added for them. - One test was renamed because it contained `__`. - Some tests were refactored. - The ActiveModelSerializers::Deserialization module is now called Adapter instead of ActiveModelSerializers::Adapter. - The changelog was added for rails-api#1535
- Loading branch information
Yohan Robert
committed
Feb 29, 2016
1 parent
8a04005
commit d935acc
Showing
24 changed files
with
790 additions
and
608 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
module ActiveModel | ||
class Serializer | ||
module Adapter | ||
class << self | ||
def create(resource, options = {}) | ||
warn "Calling deprecated ActiveModel::Serializer::Adater in #{caller[0..2].join(', ')}. Please use ActiveModelSerializers::Adapter" | ||
ActiveModelSerializers::Adapter.create(resource, options) | ||
end | ||
|
||
# @see ActiveModel::Serializer::Adapter.lookup | ||
def adapter_class(adapter) | ||
warn "Calling deprecated ActiveModel::Serializer::Adater in #{caller[0..2].join(', ')}. Please use ActiveModelSerializers::Adapter" | ||
ActiveModelSerializers::Adapter.adapter_class(adapter) | ||
end | ||
|
||
# @return Hash<adapter_name, adapter_class> | ||
def adapter_map | ||
warn "Calling deprecated ActiveModel::Serializer::Adater in #{caller[0..2].join(', ')}. Please use ActiveModelSerializers::Adapter" | ||
ActiveModelSerializers::Adapter.adapter_map | ||
end | ||
|
||
# @return [Array<Symbol>] list of adapter names | ||
def adapters | ||
warn "Calling deprecated ActiveModel::Serializer::Adater in #{caller[0..2].join(', ')}. Please use ActiveModelSerializers::Adapter" | ||
ActiveModelSerializers::Adapter.adapters | ||
end | ||
|
||
# Adds an adapter 'klass' with 'name' to the 'adapter_map' | ||
# Names are stringified and underscored | ||
# @param name [Symbol, String, Class] name of the registered adapter | ||
# @param klass [Class] adapter class itself, optional if name is the class | ||
# @example | ||
# AMS::Adapter.register(:my_adapter, MyAdapter) | ||
# @note The registered name strips out 'ActiveModel::Serializer::Adapter::' | ||
# so that registering 'ActiveModel::Serializer::Adapter::Json' and | ||
# 'Json' will both register as 'json'. | ||
def register(name, klass = name) | ||
warn "Calling deprecated ActiveModel::Serializer::Adater in #{caller[0..2].join(', ')}. Please use ActiveModelSerializers::Adapter" | ||
ActiveModelSerializers::Adapter.register(name, klass) | ||
end | ||
|
||
# @param adapter [String, Symbol, Class] name to fetch adapter by | ||
# @return [ActiveModel::Serializer::Adapter] subclass of Adapter | ||
# @raise [UnknownAdapterError] | ||
def lookup(adapter) | ||
warn "Calling deprecated ActiveModel::Serializer::Adater in #{caller[0..2].join(', ')}. Please use ActiveModelSerializers::Adapter" | ||
ActiveModelSerializers::Adapter.lookup(adapter) | ||
end | ||
end | ||
|
||
# Gotta be at the bottom to use the code above it :( | ||
require 'active_model/serializer/adapter/base' | ||
require 'active_model/serializer/adapter/null' | ||
require 'active_model/serializer/adapter/attributes' | ||
require 'active_model/serializer/adapter/json' | ||
require 'active_model/serializer/adapter/json_api' | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module ActiveModel | ||
class Serializer | ||
module Adapter | ||
class Attributes < DelegateClass(ActiveModelSerializers::Adapter::Attributes) | ||
def initialize(serializer, options = {}) | ||
warn "Calling deprecated ActiveModel::Serializer::Adater::Attributes in #{caller[0..2].join(', ')}. Please use ActiveModelSerializers::Adapter::Attributes" | ||
super(ActiveModelSerializers::Adapter::Attributes.new(serializer, options)) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module ActiveModel | ||
class Serializer | ||
module Adapter | ||
Base = ActiveModelSerializers::Adapter::Base | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module ActiveModel | ||
class Serializer | ||
module Adapter | ||
class Json < DelegateClass(ActiveModelSerializers::Adapter::Json) | ||
def initialize(serializer, options = {}) | ||
warn "Calling deprecated ActiveModel::Serializer::Adater::Json in #{caller[0..2].join(', ')}. Please use ActiveModelSerializers::Adapter::Json" | ||
super(ActiveModelSerializers::Adapter::Json.new(serializer, options)) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module ActiveModel | ||
class Serializer | ||
module Adapter | ||
class JsonApi < DelegateClass(ActiveModelSerializers::Adapter::JsonApi) | ||
def initialize(serializer, options = {}) | ||
warn "Calling deprecated ActiveModel::Serializer::Adater::JsonApi in #{caller[0..2].join(', ')}. Please use ActiveModelSerializers::Adapter::JsonApi" | ||
super(ActiveModelSerializers::Adapter::JsonApi.new(serializer, options)) | ||
end | ||
end | ||
end | ||
end | ||
end |
13 changes: 0 additions & 13 deletions
13
lib/active_model/serializer/adapter/json_api/api_objects.rb
This file was deleted.
Oops, something went wrong.
52 changes: 0 additions & 52 deletions
52
lib/active_model/serializer/adapter/json_api/api_objects/relationship.rb
This file was deleted.
Oops, something went wrong.
39 changes: 0 additions & 39 deletions
39
lib/active_model/serializer/adapter/json_api/api_objects/resource_identifier.rb
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module ActiveModel | ||
class Serializer | ||
module Adapter | ||
class Null < DelegateClass(ActiveModelSerializers::Adapter::Null) | ||
def initialize(serializer, options = {}) | ||
warn "Calling deprecated ActiveModel::Serializer::Adater::Null in #{caller[0..2].join(', ')}. Please use ActiveModelSerializers::Adapter::Null" | ||
super(ActiveModelSerializers::Adapter::Null.new(serializer, options)) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module ActiveModelSerializers | ||
module Adapter | ||
class JsonApi | ||
class Meta | ||
def initialize(serializer) | ||
@object = serializer.object | ||
@scope = serializer.scope | ||
|
||
# Use the return value of the block unless it is nil. | ||
if serializer._meta.respond_to?(:call) | ||
@value = instance_eval(&serializer._meta) | ||
else | ||
@value = serializer._meta | ||
end | ||
end | ||
|
||
def as_json | ||
@value | ||
end | ||
|
||
protected | ||
|
||
attr_reader :object, :scope | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.