Document Serializer settings and private api [ci skip]

This commit is contained in:
Benjamin Fleischer 2015-12-10 15:08:22 -06:00
parent 386a567dfc
commit bf8270b8b4
2 changed files with 5 additions and 0 deletions

View File

@ -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)

View File

@ -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) }