@@ -8,16 +8,26 @@ defmodule Mix.PowAssent do
8
8
def validate_schema_args! ( [ schema , plural | _rest ] = args , task ) do
9
9
cond do
10
10
not schema_valid? ( schema ) ->
11
- raise_invalid_schema_args_error! ( "Expected the schema argument, #{ inspect schema } , to be a valid module name" , task )
11
+ raise_invalid_schema_args_error! (
12
+ "Expected the schema argument, #{ inspect ( schema ) } , to be a valid module name" ,
13
+ task
14
+ )
15
+
12
16
not plural_valid? ( plural ) ->
13
- raise_invalid_schema_args_error! ( "Expected the plural argument, #{ inspect plural } , to be all lowercase using snake_case convention" , task )
17
+ raise_invalid_schema_args_error! (
18
+ "Expected the plural argument, #{ inspect ( plural ) } , to be all lowercase using snake_case convention" ,
19
+ task
20
+ )
21
+
14
22
true ->
15
23
schema_options_from_args ( args )
16
24
end
17
25
end
26
+
18
27
def validate_schema_args! ( [ _schema | _rest ] , task ) do
19
28
raise_invalid_schema_args_error! ( "Invalid arguments" , task )
20
29
end
30
+
21
31
def validate_schema_args! ( [ ] , _task ) , do: schema_options_from_args ( )
22
32
23
33
defp schema_valid? ( schema ) , do: schema =~ ~r/ ^[A-Z]\w *(\. [A-Z]\w *)*$/
@@ -35,6 +45,10 @@ defmodule Mix.PowAssent do
35
45
end
36
46
37
47
defp schema_options_from_args ( _opts \\ [ ] )
38
- defp schema_options_from_args ( [ schema , plural | _rest ] ) , do: % { schema_name: schema , schema_plural: plural }
39
- defp schema_options_from_args ( _any ) , do: % { schema_name: "UserIdentities.UserIdentity" , schema_plural: "user_identities" }
48
+
49
+ defp schema_options_from_args ( [ schema , plural | _rest ] ) ,
50
+ do: % { schema_name: schema , schema_plural: plural }
51
+
52
+ defp schema_options_from_args ( _any ) ,
53
+ do: % { schema_name: "UserIdentities.UserIdentity" , schema_plural: "user_identities" }
40
54
end
0 commit comments