Sha256: b2853e5c52cad8211a12b1dbd7c8a7ea9c4a30cf4350eb3fe43feffb16d53fe4

Contents?: true

Size: 736 Bytes

Versions: 1

Compression:

Stored size: 736 Bytes

Contents

# frozen_string_literal: true

require "rom/constants"

module ROM
  module Plugins
    module Relation
      # Allows relations to access all other relations through registry
      #
      # For now this plugin is always enabled
      #
      # @api public
      class RegistryReader < ::Module
        EMPTY_REGISTRY = EMPTY_HASH

        # @api private
        attr_reader :relations

        # @api private
        def initialize(relations:)
          @relations = relations
          define_readers!
        end

        private

        # @api private
        def define_readers!
          relations.each do |name|
            define_method(name) { registry.relations[name] }
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rom-6.0.0.alpha1 lib/rom/plugins/relation/registry_reader.rb