mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
merge upstream update fieldset
This commit is contained in:
@@ -21,7 +21,6 @@ module ActiveModel
|
||||
def self.attributes(*attrs)
|
||||
@_attributes.concat attrs
|
||||
|
||||
|
||||
attrs.each do |attr|
|
||||
define_method attr do
|
||||
object.read_attribute_for_serialization(attr)
|
||||
@@ -29,6 +28,14 @@ module ActiveModel
|
||||
end
|
||||
end
|
||||
|
||||
def self.attribute(attr, options = {})
|
||||
key = options.fetch(:key, attr)
|
||||
@_attributes.concat [key]
|
||||
define_method key do
|
||||
object.read_attribute_for_serialization(attr)
|
||||
end unless method_defined?(key)
|
||||
end
|
||||
|
||||
# Defines an association in the object should be rendered.
|
||||
#
|
||||
# The serializer object should implement the association name
|
||||
@@ -83,8 +90,7 @@ module ActiveModel
|
||||
def self.adapter
|
||||
adapter_class = case config.adapter
|
||||
when Symbol
|
||||
class_name = "ActiveModel::Serializer::Adapter::#{config.adapter.to_s.classify}"
|
||||
class_name.safe_constantize
|
||||
ActiveModel::Serializer::Adapter.adapter_class(config.adapter)
|
||||
when Class
|
||||
config.adapter
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user