We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6eed333 commit 075aafbCopy full SHA for 075aafb
lib/anchor/schema.rb
@@ -1,5 +1,7 @@
1
module Anchor
2
class Schema
3
+ class DuplicateTypeError < StandardError; end
4
+
5
class << self
6
Register = Struct.new(:resources, :enums, keyword_init: true)
7
@@ -9,6 +11,9 @@ def register
9
11
10
12
def resource(resource)
13
@resources ||= []
14
+ if @resources.map(&:anchor_schema_name).include?(resource.anchor_schema_name)
15
+ raise DuplicateTypeError, "A resource with type name '#{resource.anchor_schema_name}' has already been registered."
16
+ end
17
@resources.push(resource)
18
end
19
0 commit comments