mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-24 14:56:50 +00:00
rename simple adapter to json
This commit is contained in:
parent
3dd4928279
commit
6496b08464
@ -2,7 +2,7 @@ module ActiveModel
|
|||||||
class Serializer
|
class Serializer
|
||||||
class Adapter
|
class Adapter
|
||||||
extend ActiveSupport::Autoload
|
extend ActiveSupport::Autoload
|
||||||
autoload :SimpleAdapter
|
autoload :JsonAdapter
|
||||||
autoload :NullAdapter
|
autoload :NullAdapter
|
||||||
autoload :JsonApiAdapter
|
autoload :JsonApiAdapter
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
module ActiveModel
|
module ActiveModel
|
||||||
class Serializer
|
class Serializer
|
||||||
class Adapter
|
class Adapter
|
||||||
class SimpleAdapter < Adapter
|
class JsonAdapter < Adapter
|
||||||
def serializable_hash(options = {})
|
def serializable_hash(options = {})
|
||||||
serializer.attributes.each_with_object({}) do |(attr, value), h|
|
serializer.attributes.each_with_object({}) do |(attr, value), h|
|
||||||
h[attr] = value
|
h[attr] = value
|
||||||
@ -6,7 +6,7 @@ module ActiveModel
|
|||||||
|
|
||||||
included do |base|
|
included do |base|
|
||||||
base.config.array_serializer = ActiveModel::Serializer::ArraySerializer
|
base.config.array_serializer = ActiveModel::Serializer::ArraySerializer
|
||||||
base.config.adapter = :simple
|
base.config.adapter = :json
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
require "active_model"
|
require "active_model"
|
||||||
require "active_model/serializer/version"
|
require "active_model/serializer/version"
|
||||||
require "active_model/serializer"
|
require "active_model/serializer"
|
||||||
require "active_model/serializer/adapter/simple_adapter"
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
require 'action_controller'
|
require 'action_controller'
|
||||||
|
|||||||
@ -3,12 +3,12 @@ require 'test_helper'
|
|||||||
module ActiveModel
|
module ActiveModel
|
||||||
class Serializer
|
class Serializer
|
||||||
class Adapter
|
class Adapter
|
||||||
class SimpleAdapterTest < Minitest::Test
|
class JsonAdapterTest < Minitest::Test
|
||||||
def setup
|
def setup
|
||||||
@profile = Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' })
|
@profile = Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' })
|
||||||
@profile_serializer = ProfileSerializer.new(@profile)
|
@profile_serializer = ProfileSerializer.new(@profile)
|
||||||
|
|
||||||
@adapter = SimpleAdapter.new(@profile_serializer)
|
@adapter = JsonAdapter.new(@profile_serializer)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_serializable_hash
|
def test_serializable_hash
|
||||||
@ -11,7 +11,7 @@ module ActiveModel
|
|||||||
|
|
||||||
def test_returns_default_adapter
|
def test_returns_default_adapter
|
||||||
adapter = ActiveModel::Serializer.adapter
|
adapter = ActiveModel::Serializer.adapter
|
||||||
assert_equal ActiveModel::Serializer::Adapter::SimpleAdapter, adapter
|
assert_equal ActiveModel::Serializer::Adapter::JsonAdapter, adapter
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_overwrite_adapter_with_symbol
|
def test_overwrite_adapter_with_symbol
|
||||||
|
|||||||
@ -8,7 +8,7 @@ module ActiveModel
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_adapter
|
def test_adapter
|
||||||
assert_equal :simple, ActiveModel::Serializer.config.adapter
|
assert_equal :json, ActiveModel::Serializer.config.adapter
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user