Sha256: 6530b4821f8ef0c07bc9a265f658322775e156ec805505cfbfeefe5c4f034415

Contents?: true

Size: 771 Bytes

Versions: 3

Compression:

Stored size: 771 Bytes

Contents

module ROM
  module Plugins
    module Relation
      EMPTY_REGISTRY = RelationRegistry.new.freeze

      # Allows relations to access all other relations through registry
      #
      # For now this plugin is always enabled
      #
      # @api public
      module RegistryReader
        # @api private
        def self.included(klass)
          super
          klass.option :__registry__, type: RelationRegistry, default: EMPTY_REGISTRY, reader: true
        end

        # @api private
        def respond_to_missing?(name, _include_private = false)
          __registry__.key?(name) || super
        end

        private

        # @api private
        def method_missing(name, *)
          __registry__.fetch(name) { super }
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rom-2.0.2 lib/rom/plugins/relation/registry_reader.rb
rom-2.0.1 lib/rom/plugins/relation/registry_reader.rb
rom-2.0.0 lib/rom/plugins/relation/registry_reader.rb