Class: Types::BaseEnum

Inherits:
GraphQL::Schema::Enum
  • Object
show all
Defined in:
app/graphql/types/base_enum.rb

Class Method Summary collapse

Class Method Details

.enumObject

Returns an indifferent access hash with the key being the downcased name of the attribute and the value being the Ruby value (either the explicit `value` passed or the same as the value attr).


14
15
16
# File 'app/graphql/types/base_enum.rb', line 14

def enum
  @enum_values ||= {}.with_indifferent_access
end

.value(*args, **kwargs, &block) ⇒ Object


6
7
8
9
10
# File 'app/graphql/types/base_enum.rb', line 6

def value(*args, **kwargs, &block)
  enum[args[0].downcase] = kwargs[:value] || args[0]

  super(*args, **kwargs, &block)
end