@@ -106,16 +106,17 @@ add_path(Path0, ParseFun, ValidationFun) ->
106106% % from the internal storage. If there is no such key in the storage, an
107107% % exception will be thrown.
108108-spec load (Key :: string ()) -> jesse :json_term () | no_return ().
109- load (Key ) ->
109+ load (Key ) when is_list ( Key ) ->
110110 Table = create_table (table_name ()),
111- case ets :match_object (Table , {'_' , Key , '_' , '_' }) of
112- % % ID
113- [{_SourceKey , Key , _Mtime , Schema }] ->
111+ % % ID
112+ Id = Key ,
113+ case ets :match_object (Table , {'_' , Id , '_' , '_' }) of
114+ [{_SourceKey , Id , _Mtime , Schema }] ->
114115 Schema ;
115116 [] ->
117+ % % SourceKey (URI)
116118 SourceKey = jesse_state :canonical_path (Key , Key ),
117119 case ets :match_object (Table , {SourceKey , '_' , '_' , '_' }) of
118- % % Source (URI)
119120 [{SourceKey , _Key , _Mtime , Schema }] ->
120121 Schema ;
121122 _ ->
@@ -129,7 +130,7 @@ load(Key) ->
129130% % http: or https: URI scheme. If this fails as well, an exception will be
130131% % thrown.
131132-spec load_uri (Key :: string ()) -> jesse :json_term () | no_return ().
132- load_uri (Key ) ->
133+ load_uri (Key ) when is_list ( Key ) ->
133134 try
134135 load (Key )
135136 catch
@@ -147,12 +148,14 @@ load_all() ->
147148% % @doc Deletes a schema definition from the internal storage associated with,
148149% % or sourced with the key `Key'.
149150-spec delete (Key :: string ()) -> ok .
150- delete (Key0 ) ->
151- Key = jesse_state :canonical_path (Key0 , Key0 ),
151+ delete (Key ) when is_list (Key ) ->
152152 Table = create_table (table_name ()),
153- SourceKey = Key ,
153+ % % ID
154+ Id = Key ,
155+ ets :match_delete (Table , {'_' , Id , '_' , '_' }),
156+ % % SourceKey (URI)
157+ SourceKey = jesse_state :canonical_path (Key , Key ),
154158 ets :match_delete (Table , {SourceKey , '_' , '_' , '_' }),
155- ets :match_delete (Table , {'_' , Key , '_' , '_' }),
156159 ok .
157160
158161% %% Internal functions
0 commit comments