Sha256: 21c668df8b4208892182a3cf8dc9ff2047e0f44962fc4591f113a24ef29d8138

Contents?: true

Size: 697 Bytes

Versions: 3

Compression:

Stored size: 697 Bytes

Contents

# frozen_string_literal: true
module GraphQL
  module Define
    class DefinedObjectProxy
      def initialize(target)
        @target = target
        @dictionary = target.class.dictionary
      end

      def types
        GraphQL::Define::TypeDefiner.instance
      end

      def method_missing(name, *args, &block)
        definition = @dictionary[name]
        if definition
          definition.call(@target, *args, &block)
        else
          msg = "#{@target.class.name} can't define '#{name}'"
          raise NoMethodError, msg, caller
        end
      end

      def respond_to_missing?(name, include_private = false)
        @dictionary[name] || super
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
graphql-1.4.5 lib/graphql/define/defined_object_proxy.rb
graphql-1.4.4 lib/graphql/define/defined_object_proxy.rb
graphql-1.4.3 lib/graphql/define/defined_object_proxy.rb