View Source a_tree (a_tree v0.3.2)
A module for interacting with an ATree
.
Examples
1> {ok, Tree} = a_tree:new([
{boolean, <<"private">>},
{string, <<"country">>},
{integer, <<"exchange_id">>},
{string, <<"city">>},
{string_list, <<"deals">>},
{integer_list, <<"segment_ids">>}
]).
2> ok = a_tree:insert(Tree, 1, <<"exchange_id = 1 and not private and deals one of [\"deal-1\", \"deal-2\"]">>).
3> ok = a_tree:insert(Tree, 2, <<"exchange_id = 1 and not private and deals one of [\"deal-2\", \"deal-3\"] and segment_ids one of [1, 2, 3, 4]">>).
4> ok = a_tree:insert(Tree, 3, <<"exchange_id = 1 and not private and deals one of [\"deal-2\", \"deal-3\"] and segment_ids one of [5, 6, 7, 8] and country in [\"CA\", \"US\"]">>).
5> {ok, Results} = a_tree:search(Tree, [
{<<"private">>, false},
{<<"exchange_id">>, 1},
{<<"deals">>, [<<"deal-1">>, <<"deal-3">>]},
{<<"segment_ids">>, [2, 3]},
{<<"country">>, <<"CA">>}
]).
Summary
Types
-opaque atree()
-type attribute() :: {attribute_type(), attribute_name()}.
-type attribute_name() :: binary().
-type attribute_type() :: boolean | integer | string | integer_list | string_list.
-type event() :: [{attribute_name(), attribute_value()}].
-type user_id() :: non_neg_integer().
Functions
Remove the specified boolean expression from the atree/0
.
Insert a new arbitrary boolean expression inside the atree/0
with the specified user_id/0
.
The boolean expression must contain defined attributes with the correct types otherwise an error will be returned.
Create a new atree/0
.
The attributes must all be different otherwise an error will be returned.
Search for boolean expressions that match the specified event.
Export the atree/0
to Graphviz format.