Class: GraphqlRails::Model::FindOrBuildGraphqlTypeClass

Inherits:
Object
  • Object
show all
Includes:
Service
Defined in:
lib/graphql_rails/model/find_or_build_graphql_type_class.rb

Overview

Initializes class to define graphql type and fields.

Instance Method Summary collapse

Constructor Details

#initialize(name:, type_name:, parent_class:, description: nil, implements: []) ⇒ FindOrBuildGraphqlTypeClass

Returns a new instance of FindOrBuildGraphqlTypeClass.



12
13
14
15
16
17
18
19
# File 'lib/graphql_rails/model/find_or_build_graphql_type_class.rb', line 12

def initialize(name:, type_name:, parent_class:, description: nil, implements: [])
  @name = name
  @type_name = type_name
  @description = description
  @new_class = false
  @parent_class = parent_class
  @implements = implements
end

Instance Method Details

#klassObject



21
22
23
# File 'lib/graphql_rails/model/find_or_build_graphql_type_class.rb', line 21

def klass
  @klass ||= Object.const_defined?(type_name) && Object.const_get(type_name) || build_graphql_type_klass
end

#new_class?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/graphql_rails/model/find_or_build_graphql_type_class.rb', line 25

def new_class?
  new_class
end