Method: Types::EnumHelpers.enum_from_array
- Defined in:
- app/graphql/types/enum_helpers.rb
.enum_from_array(array, graphql_enum_name) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/graphql/types/enum_helpers.rb', line 19 def self.enum_from_array(array, graphql_enum_name) enum_values = array.map(&:to_s) existing_enum = Types::GraphqlTypeUtils.get_or_check_existing_constant(graphql_enum_name) return existing_enum if existing_enum Object.const_set(graphql_enum_name, Class.new(Types::BaseEnum) do graphql_name(graphql_enum_name) enum_values.each do |val| value val, description: val.titleize end end) end |