@@ -108,8 +108,8 @@ def self.serialization_adapter_instance
108108 @serialization_adapter_instance ||= ActiveModelSerializers ::Adapter ::Attributes
109109 end
110110
111- # Configuration options may also be set in
112- # Serializers and Adapters
111+ # Preferred interface is ActiveModelSerializers.config
112+ # BEGIN DEFAULT CONFIGURATION
113113 config . collection_serializer = ActiveModel ::Serializer ::CollectionSerializer
114114 config . serializer_lookup_enabled = true
115115
@@ -159,6 +159,7 @@ def config.array_serializer
159159 config . serializer_lookup_chain = ActiveModelSerializers ::LookupChain ::DEFAULT . dup
160160
161161 config . schema_path = 'test/support/schemas'
162+ # END DEFAULT CONFIGURATION
162163
163164 with_options instance_writer : false , instance_reader : false do |serializer |
164165 serializer . class_attribute :_attributes_data # @api private
@@ -180,12 +181,14 @@ def self.inherited(base)
180181 base . _links = _links . dup
181182 end
182183
183- # keys of attributes
184+ # @return [Array<Symbol>] Key names of declared attributes
184185 # @see Serializer::attribute
185186 def self . _attributes
186187 _attributes_data . keys
187188 end
188189
190+ # BEGIN SERIALIZER MACROS
191+
189192 # @example
190193 # class AdminAuthorSerializer < ActiveModel::Serializer
191194 # attributes :id, :name, :recent_edits
@@ -214,18 +217,6 @@ def self.attribute(attr, options = {}, &block)
214217 _attributes_data [ key ] = Attribute . new ( attr , options , block )
215218 end
216219
217- # @api private
218- # maps attribute value to explicit key name
219- # @see Serializer::attribute
220- # @see ActiveModel::Serializer::Caching#fragmented_attributes
221- def self . _attributes_keys
222- _attributes_data
223- . each_with_object ( { } ) do |( key , attr ) , hash |
224- next if key == attr . name
225- hash [ attr . name ] = { key : key }
226- end
227- end
228-
229220 # @param [Symbol] name of the association
230221 # @param [Hash<Symbol => any>] options for the reflection
231222 # @return [void]
@@ -302,6 +293,8 @@ def self.type(type)
302293 self . _type = type && type . to_s
303294 end
304295
296+ # END SERIALIZER MACROS
297+
305298 attr_accessor :object , :root , :scope
306299
307300 # `scope_name` is set as :current_user by default in the controller.
0 commit comments