File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -133,14 +133,16 @@ defmodule Application do
133
133
@ doc """
134
134
Returns the value for `key` in `app`'s specification.
135
135
136
- See `spec/1` for the supporte keys. If the given
136
+ See `spec/1` for the supported keys. If the given
137
137
specification parameter does not exist, this function
138
- will raise.
138
+ will raise. Returns `nil` if the application is not loaded.
139
139
"""
140
- @ spec spec ( app , key ) :: value
140
+ @ spec spec ( app , key ) :: value | nil
141
141
def spec ( app , key ) when key in @ application_keys do
142
- { :ok , value } = :application . get_key ( app , key )
143
- value
142
+ case :application . get_key ( app , key ) do
143
+ { :ok , value } -> value
144
+ :undefined -> nil
145
+ end
144
146
end
145
147
146
148
@ doc """
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ defmodule ApplicationTest do
38
38
test "application specification" do
39
39
assert is_list Application . spec ( :elixir )
40
40
assert Application . spec ( :unknown ) == nil
41
+ assert Application . spec ( :unknown , :description ) == nil
41
42
42
43
assert Application . spec ( :elixir , :description ) == 'elixir'
43
44
assert_raise FunctionClauseError , fn -> Application . spec ( :elixir , :unknown ) end
You can’t perform that action at this time.
0 commit comments