Sha256: 973a6540d64f63a51ba95e05e98a2f7bb24a7b836ac7d393ac3174306c7b77ec
Contents?: true
Size: 844 Bytes
Versions: 6
Compression:
Stored size: 844 Bytes
Contents
module Yaks class Mapper class HasMany < Association include Util def initialize(options) super @collection_mapper = options.fetch(:collection_mapper, Undefined) end def map_resource(collection, context) return NullResource.new(collection: true) if collection.nil? policy = context.fetch(:policy) item_mapper = resolve_association_mapper(policy) context = context.merge(item_mapper: item_mapper) collection_mapper(collection, policy).new(context).call(collection) end def collection_mapper(collection, policy) return @collection_mapper unless @collection_mapper.equal? Undefined policy.derive_mapper_from_object(collection) end def singular_name singularize(name.to_s) end end end end
Version data entries
6 entries across 6 versions & 2 rubygems