You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2014/04/22 12:08:33 UTC
[7/9] config commit: updated refs/heads/1843-feature-bigcouch to
31d14bc
Guard get/set/delete to require list arguments
BugzID: 25731
Project: http://git-wip-us.apache.org/repos/asf/couchdb-config/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-config/commit/fe9bab23
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-config/tree/fe9bab23
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-config/diff/fe9bab23
Branch: refs/heads/1843-feature-bigcouch
Commit: fe9bab239e8a24dd74ba4297f9ae8409676699c7
Parents: 6859d11
Author: Adam Kocoloski <ad...@cloudant.com>
Authored: Thu Dec 12 07:19:00 2013 -0500
Committer: Adam Kocoloski <ad...@cloudant.com>
Committed: Thu Dec 12 07:19:00 2013 -0500
----------------------------------------------------------------------
src/config.erl | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-config/blob/fe9bab23/src/config.erl
----------------------------------------------------------------------
diff --git a/src/config.erl b/src/config.erl
index 98b5221..1a728b0 100644
--- a/src/config.erl
+++ b/src/config.erl
@@ -124,7 +124,7 @@ to_boolean(Bool) when is_boolean(Bool) ->
get(Section) when is_binary(Section) ->
?MODULE:get(binary_to_list(Section));
-get(Section) ->
+get(Section) when is_list(Section) ->
Matches = ets:match(?MODULE, {{Section, '$1'}, '$2'}),
[{Key, Value} || [Key, Value] <- Matches].
@@ -133,7 +133,7 @@ get(Section, Key) ->
get(Section, Key, Default) when is_binary(Section) and is_binary(Key) ->
?MODULE:get(binary_to_list(Section), binary_to_list(Key), Default);
-get(Section, Key, Default) ->
+get(Section, Key, Default) when is_list(Section), is_list(Key) ->
case ets:lookup(?MODULE, {Section, Key}) of
[] -> Default;
[{_, Match}] -> Match
@@ -149,7 +149,8 @@ set(Section, Key, Value, Reason) ->
set(Sec, Key, Val, Persist, Reason) when is_binary(Sec) and is_binary(Key) ->
?MODULE:set(binary_to_list(Sec), binary_to_list(Key), Val, Persist, Reason);
-set(Section, Key, Value, Persist, Reason) ->
+set(Section, Key, Value, Persist, Reason)
+ when is_list(Section), is_list(Key), is_list(Value) ->
gen_server:call(?MODULE, {set, Section, Key, Value, Persist, Reason}).
@@ -165,7 +166,7 @@ delete(Section, Key, Reason) ->
delete(Sec, Key, Persist, Reason) when is_binary(Sec) and is_binary(Key) ->
delete(binary_to_list(Sec), binary_to_list(Key), Persist, Reason);
-delete(Section, Key, Persist, Reason) ->
+delete(Section, Key, Persist, Reason) when is_list(Section), is_list(Key) ->
gen_server:call(?MODULE, {delete, Section, Key, Persist, Reason}).