Sha256: f748c5759d3ea83690958ae36617b1dd0b6bd156f0a439ef75dbb41c86194ed4

Contents?: true

Size: 800 Bytes

Versions: 4

Compression:

Stored size: 800 Bytes

Contents

module Hanami
  module Model
    # Mapped proxy for ROM relations.
    #
    # It eliminates the need of use #as for repository queries
    #
    # @since 1.0.0.beta1
    # @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.beta1
      # @api private
      MAPPER_NAME = :entity

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

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hanami-model-1.0.0.rc1 lib/hanami/model/mapped_relation.rb
hanami-model-1.0.0.beta3 lib/hanami/model/mapped_relation.rb
hanami-model-1.0.0.beta2 lib/hanami/model/mapped_relation.rb
hanami-model-1.0.0.beta1 lib/hanami/model/mapped_relation.rb