-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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 #1535
- Loading branch information
Showing
24 changed files
with
823 additions
and
614 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,49 @@ | ||
module ActiveModel | ||
class Serializer | ||
# @deprecated Use ActiveModelSerializers::Adapter instead | ||
module Adapter | ||
class << self | ||
def create(resource, options = {}) | ||
warn_deprecation | ||
ActiveModelSerializers::Adapter.create(resource, options) | ||
end | ||
|
||
def adapter_class(adapter) | ||
warn_deprecation | ||
ActiveModelSerializers::Adapter.adapter_class(adapter) | ||
end | ||
|
||
def adapter_map | ||
warn_deprecation | ||
ActiveModelSerializers::Adapter.adapter_map | ||
end | ||
|
||
def adapters | ||
warn_deprecation | ||
ActiveModelSerializers::Adapter.adapters | ||
end | ||
|
||
def register(name, klass = name) | ||
warn_deprecation | ||
ActiveModelSerializers::Adapter.register(name, klass) | ||
end | ||
|
||
def lookup(adapter) | ||
warn_deprecation | ||
ActiveModelSerializers::Adapter.lookup(adapter) | ||
end | ||
|
||
def warn_deprecation | ||
warn "Calling deprecated #{name} (#{__FILE__}) from #{caller[1..3].join(', ')}. Please use ActiveModelSerializers::Adapter" | ||
end | ||
private :warn_deprecation | ||
end | ||
|
||
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,14 @@ | ||
require 'active_model_serializers/adapter/attributes' | ||
|
||
module ActiveModel | ||
class Serializer | ||
module Adapter | ||
class Attributes < DelegateClass(ActiveModelSerializers::Adapter::Attributes) | ||
def initialize(serializer, options = {}) | ||
warn "Calling deprecated #{self.class.name} (#{__FILE__}) from #{caller[0..2].join(', ')}. Please use #{self.class.name.sub('ActiveModel::Serializer', 'ActiveModelSerializers')}" | ||
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,16 @@ | ||
module ActiveModel | ||
class Serializer | ||
module Adapter | ||
class Base < DelegateClass(ActiveModelSerializers::Adapter::Base) | ||
def self.inherited(base) | ||
warn "Inheriting deprecated ActiveModel::Serializer::Adapter::Base in #{caller[0..2].join(', ')}. Please use ActiveModelSerializers::Adapter::Base" | ||
super | ||
end | ||
|
||
def initialize(serializer, options = {}) | ||
super(ActiveModelSerializers::Adapter::Base.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,14 @@ | ||
require 'active_model_serializers/adapter/json' | ||
|
||
module ActiveModel | ||
class Serializer | ||
module Adapter | ||
class Json < DelegateClass(ActiveModelSerializers::Adapter::Json) | ||
def initialize(serializer, options = {}) | ||
warn "Calling deprecated #{self.class.name} (#{__FILE__}) from #{caller[0..2].join(', ')}. Please use #{self.class.name.sub('ActiveModel::Serializer', 'ActiveModelSerializers')}" | ||
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,14 @@ | ||
require 'active_model_serializers/adapter/json_api' | ||
|
||
module ActiveModel | ||
class Serializer | ||
module Adapter | ||
class JsonApi < DelegateClass(ActiveModelSerializers::Adapter::JsonApi) | ||
def initialize(serializer, options = {}) | ||
warn "Calling deprecated #{self.class.name} (#{__FILE__}) from #{caller[0..2].join(', ')}. Please use #{self.class.name.sub('ActiveModel::Serializer', 'ActiveModelSerializers')}" | ||
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.
56 changes: 0 additions & 56 deletions
56
lib/active_model/serializer/adapter/json_api/api_objects/relationship.rb
This file was deleted.
Oops, something went wrong.
40 changes: 0 additions & 40 deletions
40
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,14 @@ | ||
require 'active_model_serializers/adapter/null' | ||
|
||
module ActiveModel | ||
class Serializer | ||
module Adapter | ||
class Null < DelegateClass(ActiveModelSerializers::Adapter::Null) | ||
def initialize(serializer, options = {}) | ||
warn "Calling deprecated #{self.class.name} (#{__FILE__}) from #{caller[0..2].join(', ')}. Please use #{self.class.name.sub('ActiveModel::Serializer', 'ActiveModelSerializers')}" | ||
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.