Sha256: 349127c8ded78245fe7e23935b8f74c530c1eb20f44ea7d824db2abb66ee2afc

Contents?: true

Size: 936 Bytes

Versions: 47

Compression:

Stored size: 936 Bytes

Contents

# frozen_string_literal: true
module GraphQL
  class Schema
    module FindInheritedValue
      module EmptyObjects
        EMPTY_HASH = {}.freeze
        EMPTY_ARRAY = [].freeze
      end

      def self.extended(child_cls)
        child_cls.singleton_class.include(EmptyObjects)
      end

      def self.included(child_cls)
        child_cls.include(EmptyObjects)
      end

      private

      def find_inherited_value(method_name, default_value = nil)
        if self.is_a?(Class)
          superclass.respond_to?(method_name, true) ? superclass.send(method_name) : default_value
        else
          ancestors_except_self = ancestors
          ancestors_except_self.delete(self)
          ancestors_except_self.each do |ancestor|
            if ancestor.respond_to?(method_name, true)
              return ancestor.send(method_name)
            end
          end
          default_value
        end
      end
    end
  end
end

Version data entries

47 entries across 47 versions & 2 rubygems

Version Path
graphql-1.13.23 lib/graphql/schema/find_inherited_value.rb
graphql-1.13.22 lib/graphql/schema/find_inherited_value.rb
graphql-1.13.21 lib/graphql/schema/find_inherited_value.rb
graphql-1.13.20 lib/graphql/schema/find_inherited_value.rb
graphql-2.0.20 lib/graphql/schema/find_inherited_value.rb
graphql-2.0.17.2 lib/graphql/schema/find_inherited_value.rb
graphql-2.0.17.1 lib/graphql/schema/find_inherited_value.rb
graphql-2.0.19 lib/graphql/schema/find_inherited_value.rb
graphql-2.0.18 lib/graphql/schema/find_inherited_value.rb
graphql-2.0.17 lib/graphql/schema/find_inherited_value.rb
graphql-1.13.19 lib/graphql/schema/find_inherited_value.rb
graphql-1.13.18 lib/graphql/schema/find_inherited_value.rb
graphql-2.0.16 lib/graphql/schema/find_inherited_value.rb
graphql-1.13.17 lib/graphql/schema/find_inherited_value.rb
graphql-2.0.15 lib/graphql/schema/find_inherited_value.rb
graphql-2.0.14 lib/graphql/schema/find_inherited_value.rb
graphql-1.13.16 lib/graphql/schema/find_inherited_value.rb
graphql-2.0.13 lib/graphql/schema/find_inherited_value.rb
graphql-2.0.12 lib/graphql/schema/find_inherited_value.rb
graphql-1.13.15 lib/graphql/schema/find_inherited_value.rb