Sha256: f41d8c2b9daf3f45508509da7a1a1fa9b451227ebcd791a66a94c4ff91c433db

Contents?: true

Size: 562 Bytes

Versions: 1

Compression:

Stored size: 562 Bytes

Contents

module Yaks
  class Mapper
    class HasMany < Association
      def map_resource(collection, context)
        policy        = context.fetch(:policy)
        member_mapper = association_mapper(policy)
        context       = context.merge(member_mapper: member_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
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
yaks-0.4.0 lib/yaks/mapper/has_many.rb