Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Extracted is_true to new module

  • Loading branch information...
commit 36f205c4cea87083123ee21f44797ffd04c7e34b 1 parent b17a9c2
@wardbekker wardbekker authored
Showing with 35 additions and 12 deletions.
  1. +34 −0 src/riak_mongo_js_emulation.erl
  2. +1 −12 src/riak_mongo_riak.erl
View
34 src/riak_mongo_js_emulation.erl
@@ -0,0 +1,34 @@
+%%
+%% This file is part of riak_mongo
+%%
+%% Copyright (c) 2012 by Ward Bekker (ward at equanimity dot nl)
+%%
+%% Licensed under the Apache License, Version 2.0 (the "License");
+%% you may not use this file except in compliance with the License.
+%% You may obtain a copy of the License at
+%%
+%% http://www.apache.org/licenses/LICENSE-2.0
+%%
+%% Unless required by applicable law or agreed to in writing, software
+%% distributed under the License is distributed on an "AS IS" BASIS,
+%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+%% See the License for the specific language governing permissions and
+%% limitations under the License.
+%%
+
+%% @author Ward Bekker
+%%
+%% @doc Javascript value interpretation emulation
+%%
+%% @copyright 2012 by Ward Bekker (ward at equanimity dot nl)
+
+-module(riak_mongo_js_emulation).
+
+-export([is_true/1]).
+
+is_true(undefined) -> false;
+is_true(null) -> false;
+is_true(false) -> false;
+is_true(0) -> false;
+is_true(0.0) -> false;
+is_true(_) -> true.
View
13 src/riak_mongo_riak.erl
@@ -426,7 +426,7 @@ get_projection_keys([], Acc) ->
get_projection_keys([{struct, KVs}|Rest], Acc) ->
Keys = lists:usort
(lists:foldl(fun({K,V}, Acc1) ->
- case is_true(V) of
+ case riak_mongo_js_emulation:is_true(V) of
true -> [K|Acc1];
false -> Acc1
end
@@ -458,14 +458,3 @@ hex(CH) when CH < 16 ->
[ $0, integer_to_list(CH, 16) ];
hex(CH) ->
integer_to_list(CH, 16).
-
-%%
-%% we'll need this lots of places, it should probably be
-%% in a separate "js emulation" module
-%%
-is_true(undefined) -> false;
-is_true(null) -> false;
-is_true(false) -> false;
-is_true(0) -> false;
-is_true(0.0) -> false;
-is_true(_) -> true.
Please sign in to comment.
Something went wrong with that request. Please try again.