Sha256: 70bfedac3addf33e1302b41731408d72d1d388b0e01a5fd2083f5dbaf7357378

Contents?: true

Size: 776 Bytes

Versions: 8

Compression:

Stored size: 776 Bytes

Contents

module Hanami
  module Model
    # Mapped proxy for ROM relations.
    #
    # It eliminates the need to use #as for repository queries
    #
    # @since 1.0.0
    # @api private
    class MappedRelation < SimpleDelegator
      # Mapper name.
      #
      # With ROM mapping there is a link between the entity class and a generic
      # reference for it. Example: <tt>BookRepository</tt> references <tt>Book</tt>
      # as <tt>:entity</tt>.
      #
      # @since 1.0.0
      # @api private
      MAPPER_NAME = :entity

      # @since 1.0.0
      # @api private
      def self.mapper_name
        MAPPER_NAME
      end

      # @since 1.0.0
      # @api private
      def initialize(relation)
        super(relation.as(self.class.mapper_name))
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
hanami-model-1.2.0.beta2 lib/hanami/model/mapped_relation.rb
hanami-model-1.2.0.beta1 lib/hanami/model/mapped_relation.rb
hanami-model-1.1.0 lib/hanami/model/mapped_relation.rb
hanami-model-1.1.0.rc1 lib/hanami/model/mapped_relation.rb
hanami-model-1.0.4 lib/hanami/model/mapped_relation.rb
hanami-model-1.0.3 lib/hanami/model/mapped_relation.rb
hanami-model-1.1.0.beta3 lib/hanami/model/mapped_relation.rb
hanami-model-1.1.0.beta2 lib/hanami/model/mapped_relation.rb