Class: ActiveModel::Serializer::Association::HasMany
- Inherits:
-
ActiveModel::Serializer::Association
- Object
- ActiveModel::Serializer::Association
- ActiveModel::Serializer::Association::HasMany
- Defined in:
- lib/active_model/serializer/association/has_many.rb
Instance Attribute Summary
Attributes inherited from ActiveModel::Serializer::Association
#embed_ids, #embed_in_root, #embed_in_root_key, #embed_key, #embed_namespace, #embed_objects, #embedded_key, #key, #key_format, #name, #polymorphic, #root_key, #serializer_from_options
Instance Method Summary collapse
-
#initialize(name, *args) ⇒ HasMany
constructor
A new instance of HasMany.
- #options ⇒ Object
- #serializer_class(object, _) ⇒ Object
Methods inherited from ActiveModel::Serializer::Association
#build_serializer, #default_serializer, #embed=, #serializer_from_object
Constructor Details
#initialize(name, *args) ⇒ HasMany
Returns a new instance of HasMany.
5 6 7 8 9 10 11 12 |
# File 'lib/active_model/serializer/association/has_many.rb', line 5 def initialize(name, *args) super @root_key = @embedded_key.to_s @key ||= case CONFIG.default_key_type when :name then name.to_s.pluralize else "#{name.to_s.singularize}_ids" end end |
Instance Method Details
#options ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/active_model/serializer/association/has_many.rb', line 22 def if use_array_serializer? { each_serializer: }.merge! super else super end end |
#serializer_class(object, _) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/active_model/serializer/association/has_many.rb', line 14 def serializer_class(object, _) if use_array_serializer? ArraySerializer else end end |