summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Engel <tobias@sternraute.de>2013-06-13 11:16:57 +0200
committerTobias Engel <tobias@sternraute.de>2013-06-13 11:19:30 +0200
commitd49aa21366e6b77b2a0eeec8c7fc7b71b75f157e (patch)
tree89d69ab7582a9a4d8961199b7b984cb032b3b820
parentef770471dcde812c0de348e75cdb18268fa8a70f (diff)
handle non-tuple return value of TupleCB
-rw-r--r--src/osmo_util.erl13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/osmo_util.erl b/src/osmo_util.erl
index b8ef242..d4fb5b0 100644
--- a/src/osmo_util.erl
+++ b/src/osmo_util.erl
@@ -107,10 +107,15 @@ tuple_walk(Tpl, TupleCb, Args) when is_tuple(Tpl), is_function(TupleCb),
tuple_walk(Path, Tpl, TupleCb, Args) when is_list(Path), is_tuple(Tpl),
is_list(Args) ->
% call Callback
- NewTpl = TupleCb(Path, Tpl, Args),
- [TplName|TplList] = tuple_to_list(NewTpl),
- NewTplList = tuple_fieldlist_walk(Path, TplName, TplList, TupleCb, Args),
- list_to_tuple([TplName|NewTplList]);
+ RetVal = TupleCb(Path, Tpl, Args),
+ if
+ is_tuple(RetVal) ->
+ [TplName|TplList] = tuple_to_list(RetVal),
+ NewTplList = tuple_fieldlist_walk(Path, TplName, TplList, TupleCb, Args),
+ list_to_tuple([TplName|NewTplList]);
+ true ->
+ RetVal
+ end;
tuple_walk(Path, TplL, TupleCb, Args) when is_list(Path), is_list(TplL),
is_list(Args) ->
tuple_walk_list(Path, TplL, TupleCb, Args, []).