mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-22 22:06:50 +00:00
Document Serializer settings and private api [ci skip]
This commit is contained in:
parent
386a567dfc
commit
bf8270b8b4
@ -1,6 +1,7 @@
|
||||
module ActiveModel
|
||||
class Serializer
|
||||
module Attributes
|
||||
# @api private
|
||||
class Attribute
|
||||
delegate :call, to: :reader
|
||||
|
||||
@ -19,12 +20,14 @@ module ActiveModel
|
||||
end
|
||||
end
|
||||
end
|
||||
# @api private
|
||||
class AttributeReader < Attribute
|
||||
def initialize(name)
|
||||
super(name)
|
||||
@reader = ->(instance) { instance.read_attribute_for_serialization(name) }
|
||||
end
|
||||
end
|
||||
# @api private
|
||||
class AttributeBlock < Attribute
|
||||
def initialize(name, block)
|
||||
super(name)
|
||||
|
||||
@ -35,10 +35,12 @@ module ActiveModel
|
||||
@reader = self.class.build_reader(name, block)
|
||||
end
|
||||
|
||||
# @api private
|
||||
def value(instance)
|
||||
call(instance)
|
||||
end
|
||||
|
||||
# @api private
|
||||
def self.build_reader(name, block)
|
||||
if block
|
||||
->(instance) { instance.read_attribute_for_serialization(name).instance_eval(&block) }
|
||||
|
||||
Loading…
Reference in New Issue
Block a user