Sha256: 712be80ce1a0800776afd3befe893db7f0abc02f59fb122d47250d61007164a9
Contents?: true
Size: 879 Bytes
Versions: 1
Compression:
Stored size: 879 Bytes
Contents
module ActiveModel class Serializer class ArraySerializer include Enumerable delegate :each, to: :@objects attr_reader :meta, :meta_key def initialize(objects, options = {}) @resource = objects @objects = objects.map do |object| serializer_class = options.fetch( :serializer, ActiveModel::Serializer.serializer_for(object) ) serializer_class.new(object, options.except(:serializer)) end @meta = options[:meta] @meta_key = options[:meta_key] end def json_key if @objects.first @objects.first.json_key.pluralize else @resource.name.downcase.pluralize if @resource.try(:name) end end def root=(root) @objects.first.root = root if @objects.first end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
active_model_serializers-0.10.0.rc2 | lib/active_model/serializer/array_serializer.rb |