lib/rails/graphql/source.rb
# A helper method to create an enum type
A helper method to create an enum type
A helper method to create an enum type
def create_enum(enum_name, values, **xargs, &block)
            enumerator = values.each_pair if values.respond_to?(:each_pair)
            enumerator ||= values.each.with_index
            xargs = xargs.reverse_merge(once: true)
            create_type(:enum, as: enum_name.classify, **xargs) do
              indexed! if enumerator.first.last.is_a?(Numeric)
              enumerator.sort_by(&:last).map(&:first).each(&method(:add))
              instance_exec(&block) if block.present?
            end
          end
def create_enum ( enum_name , values , ** xargs , & block ) enumerator = values . each_pair if values . respond_to? ( :each_pair ) enumerator ||= values . each . with_index xargs = xargs . reverse_merge ( once : true ) create_type ( :enum , as : enum_name . classify , ** xargs ) do indexed! if enumerator . first . last . is_a? ( Numeric ) enumerator . sort_by ( & :last ) . map ( & :first ) . each ( & method ( :add ) ) instance_exec ( & block ) if block . present? end end
A helper method to create an enum type
A helper method to create an enum type
enum_name
values
xargs
block