Module: GraphQL::Modernize::RuleRegistry

Defined in:
lib/graphql/modernize/rule_registry.rb

Class Method Summary collapse

Class Method Details

.allObject



17
18
19
# File 'lib/graphql/modernize/rule_registry.rb', line 17

def all
  @rules.values.sort_by { |rule_class| rule_class..id }
end

.fetch(id) ⇒ Object



21
22
23
# File 'lib/graphql/modernize/rule_registry.rb', line 21

def fetch(id)
  @rules.fetch(id.to_s.upcase) { raise ArgumentError, "unknown rule: #{id}" }
end

.register(rule_class) ⇒ Object

Raises:

  • (ArgumentError)


10
11
12
13
14
15
# File 'lib/graphql/modernize/rule_registry.rb', line 10

def register(rule_class)
  id = rule_class..id
  raise ArgumentError, "duplicate rule id: #{id}" if @rules.key?(id)

  @rules[id] = rule_class
end