Class: RESTFramework::ActiveModelSerializerAdapterFactory
- Inherits:
-
Object
- Object
- RESTFramework::ActiveModelSerializerAdapterFactory
- Defined in:
- lib/rest_framework/serializers.rb
Overview
This is a helper factory to wrap an ActiveModelSerializer to provide a ‘serialize` method which accepts both collections and individual records. Use `.for` to build adapters.
Class Method Summary collapse
Class Method Details
.for(active_model_serializer) ⇒ Object
375 376 377 378 379 380 381 382 383 384 385 |
# File 'lib/rest_framework/serializers.rb', line 375 def self.for(active_model_serializer) return Class.new(active_model_serializer) do def serialize if self.object.respond_to?(:to_ary) return self.object.map { |r| self.class.superclass.new(r).serializable_hash } end return self.serializable_hash end end end |