Module: GraphQL::Doctor::Source::NameMangler
- Defined in:
- lib/graphql/doctor/source/name_mangler.rb
Class Method Summary collapse
Class Method Details
.graphql_name(ruby_name) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/graphql/doctor/source/name_mangler.rb', line 9 def graphql_name(ruby_name) string = ruby_name.to_s return string if string == "_" || !string.include?("_") camelized = string.split("_").map(&:capitalize).join camelized[0] = camelized[0].downcase prefix = string[/\A_+/] prefix ? "#{prefix}#{camelized}" : camelized end |
.keyword(ruby_name, loads: nil, as: nil) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/graphql/doctor/source/name_mangler.rb', line 19 def keyword(ruby_name, loads: nil, as: nil) return as.to_sym if as name = ruby_name.to_s return name.delete_suffix("_ids").sub(/([^s])\z/, "\\1s").to_sym if loads && name.end_with?("_ids") return name.delete_suffix("_id").to_sym if loads && name.end_with?("_id") name.to_sym end |