@@ -108,8 +108,8 @@ def self.serialization_adapter_instance
108
108
@serialization_adapter_instance ||= ActiveModelSerializers ::Adapter ::Attributes
109
109
end
110
110
111
- # Configuration options may also be set in
112
- # Serializers and Adapters
111
+ # Preferred interface is ActiveModelSerializers.config
112
+ # BEGIN DEFAULT CONFIGURATION
113
113
config . collection_serializer = ActiveModel ::Serializer ::CollectionSerializer
114
114
config . serializer_lookup_enabled = true
115
115
@@ -159,6 +159,7 @@ def config.array_serializer
159
159
config . serializer_lookup_chain = ActiveModelSerializers ::LookupChain ::DEFAULT . dup
160
160
161
161
config . schema_path = 'test/support/schemas'
162
+ # END DEFAULT CONFIGURATION
162
163
163
164
with_options instance_writer : false , instance_reader : false do |serializer |
164
165
serializer . class_attribute :_attributes_data # @api private
@@ -180,12 +181,14 @@ def self.inherited(base)
180
181
base . _links = _links . dup
181
182
end
182
183
183
- # keys of attributes
184
+ # @return [Array<Symbol>] Key names of declared attributes
184
185
# @see Serializer::attribute
185
186
def self . _attributes
186
187
_attributes_data . keys
187
188
end
188
189
190
+ # BEGIN SERIALIZER MACROS
191
+
189
192
# @example
190
193
# class AdminAuthorSerializer < ActiveModel::Serializer
191
194
# attributes :id, :name, :recent_edits
@@ -214,18 +217,6 @@ def self.attribute(attr, options = {}, &block)
214
217
_attributes_data [ key ] = Attribute . new ( attr , options , block )
215
218
end
216
219
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
-
229
220
# @param [Symbol] name of the association
230
221
# @param [Hash<Symbol => any>] options for the reflection
231
222
# @return [void]
@@ -302,6 +293,8 @@ def self.type(type)
302
293
self . _type = type && type . to_s
303
294
end
304
295
296
+ # END SERIALIZER MACROS
297
+
305
298
attr_accessor :object , :root , :scope
306
299
307
300
# `scope_name` is set as :current_user by default in the controller.
0 commit comments