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
297 298 299 300 301 302 303 304 305 306 307 |
# File 'lib/rest_framework/serializers.rb', line 297 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 |