debian-mirror-gitlab/app/graphql/types/base_enum.rb

23 lines
638 B
Ruby
Raw Normal View History

2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
2018-11-08 19:23:39 +05:30
module Types
class BaseEnum < GraphQL::Schema::Enum
2020-11-24 15:15:51 +05:30
extend GitlabStyleDeprecations
2019-12-26 22:10:19 +05:30
class << self
def value(*args, **kwargs, &block)
enum[args[0].downcase] = kwargs[:value] || args[0]
2020-11-24 15:15:51 +05:30
kwargs = gitlab_deprecation(kwargs)
2019-12-26 22:10:19 +05:30
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-11-08 19:23:39 +05:30
end
end