mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-24 23:06:50 +00:00
Remove SerializerSupport
This commit is contained in:
parent
0d4dfb69a9
commit
01bc534976
@ -60,8 +60,7 @@ module ActionController
|
|||||||
|
|
||||||
serializer =
|
serializer =
|
||||||
options.delete(:serializer) ||
|
options.delete(:serializer) ||
|
||||||
resource.respond_to?(:active_model_serializer) &&
|
ActiveModel::Serializer.serializer_for(resource)
|
||||||
resource.active_model_serializer
|
|
||||||
|
|
||||||
options[:scope] = serialization_scope unless options.has_key?(:scope)
|
options[:scope] = serialization_scope unless options.has_key?(:scope)
|
||||||
|
|
||||||
|
|||||||
@ -5,6 +5,10 @@ module ActiveModel
|
|||||||
base._attributes = {}
|
base._attributes = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def serializer_for(resource)
|
||||||
|
"#{resource.class.name}Serializer".safe_constantize
|
||||||
|
end
|
||||||
|
|
||||||
attr_accessor :_root, :_attributes
|
attr_accessor :_root, :_attributes
|
||||||
|
|
||||||
def root(root)
|
def root(root)
|
||||||
|
|||||||
@ -1,11 +0,0 @@
|
|||||||
require 'active_support/core_ext/string/inflections'
|
|
||||||
|
|
||||||
module ActiveModel
|
|
||||||
module SerializerSupport
|
|
||||||
def active_model_serializer
|
|
||||||
"#{self.class.name}Serializer".safe_constantize
|
|
||||||
end
|
|
||||||
|
|
||||||
alias read_attribute_for_serialization send
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@ -1,6 +1,5 @@
|
|||||||
require 'active_model'
|
require 'active_model'
|
||||||
require 'active_model/serializer'
|
require 'active_model/serializer'
|
||||||
require 'active_model/serializer_support'
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
require 'action_controller'
|
require 'action_controller'
|
||||||
@ -12,9 +11,3 @@ begin
|
|||||||
rescue LoadError
|
rescue LoadError
|
||||||
# rails not installed, continuing
|
# rails not installed, continuing
|
||||||
end
|
end
|
||||||
|
|
||||||
[:active_record, :mongoid].each do |orm|
|
|
||||||
ActiveSupport.on_load(orm) do
|
|
||||||
include ActiveModel::SerializerSupport
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|||||||
2
test/fixtures/poro.rb
vendored
2
test/fixtures/poro.rb
vendored
@ -1,6 +1,4 @@
|
|||||||
class Model
|
class Model
|
||||||
include ActiveModel::SerializerSupport
|
|
||||||
|
|
||||||
def initialize(hash={})
|
def initialize(hash={})
|
||||||
@attributes = hash
|
@attributes = hash
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,13 +0,0 @@
|
|||||||
require 'test_helper'
|
|
||||||
require 'fixtures/active_record'
|
|
||||||
require 'active_model/serializer_support'
|
|
||||||
|
|
||||||
module ActiveModel
|
|
||||||
module SerializerSupport
|
|
||||||
class Test < ActiveModel::TestCase
|
|
||||||
def test_active_model_returns_its_serializer
|
|
||||||
assert_equal ARModelSerializer, ARModel.new.active_model_serializer
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@ -1,12 +0,0 @@
|
|||||||
require 'test_helper'
|
|
||||||
require 'active_model/serializer_support'
|
|
||||||
|
|
||||||
module ActiveModel
|
|
||||||
module SerializerSupport
|
|
||||||
class Test < ActiveModel::TestCase
|
|
||||||
def test_active_model_on_poro_returns_its_serializer
|
|
||||||
assert_equal ModelSerializer, ::Model.new.active_model_serializer
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
Loading…
Reference in New Issue
Block a user