2018-09-11 19:08:34 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-05-23 07:55:14 +00:00
|
|
|
module Types
|
|
|
|
class BaseEnum < GraphQL::Schema::Enum
|
2019-11-13 12:06:22 +00:00
|
|
|
class << self
|
|
|
|
def value(*args, **kwargs, &block)
|
|
|
|
enum[args[0].downcase] = kwargs[:value] || args[0]
|
|
|
|
|
|
|
|
super(*args, **kwargs, &block)
|
|
|
|
end
|
|
|
|
|
|
|
|
# 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).
|
|
|
|
def enum
|
|
|
|
@enum_values ||= {}.with_indifferent_access
|
|
|
|
end
|
|
|
|
end
|
2018-05-23 07:55:14 +00:00
|
|
|
end
|
|
|
|
end
|