Skip to content

Commit

Permalink
Fix names clashing issue
Browse files Browse the repository at this point in the history
See xerions#23 for more information
  • Loading branch information
surik committed Jul 28, 2016
1 parent e02df13 commit 87b7f7e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions lib/subscription.ex
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ defmodule Metricman.Subscription do
("$" <> id, ids) -> ids ++ [{id |> to_downcased_atom, [], Elixir}]
(id, ids) -> ids ++ [id] end)
vars = List.foldl(exo_id, [],
fn ([?$ | id], acc) -> acc ++ [id |> to_downcased_atom]
("$" <> id, acc) -> acc ++ [id |> to_downcased_atom]
fn ([?$ | _] = id, acc) -> acc ++ [id |> to_downcased_atom]
("$" <> _ = id, acc) -> acc ++ [id |> to_downcased_atom]
(_, acc) -> acc ++ [:_]
end)
quote do
Expand All @@ -107,8 +107,8 @@ defmodule Metricman.Subscription do
|> Enum.zip(unquote(exo_id_for_match))
|> Enum.filter(fn({x, _}) -> x != :_ end)
path = List.foldl(@path ++ unquote(id), [],
fn ([?$ | id], acc) -> acc ++ [id |> to_downcased_atom]
("$" <> id, acc) -> acc ++ [id |> to_downcased_atom]
fn ([?$ | _] = id, acc) -> acc ++ [id |> to_downcased_atom]
("$" <> _ = id, acc) -> acc ++ [id |> to_downcased_atom]
(id, acc) -> acc ++ [id]
end)
opts = Keyword.merge(@opts, unquote(opts))
Expand Down
6 changes: 3 additions & 3 deletions test/subscription_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ defmodule MetricmanSubscribtionTest do
map [:used], [:ippools, :ip, :total, :used]
map [:total], [:ippools, :ip, :total, :total], @opts2
scope ['$country'] do
scope [:region, "$city"] do # it is posible to use list and string as variable name
map [:used], [:ippools, :ip, '$country', '$city', :used]
map [:total], [:ippools, :ip, "$country", "$city", :total]
scope [:region, "$region"] do # it is posible to use list and string as variable name
map [:used], [:ippools, :ip, '$country', '$region', :used]
map [:total], [:ippools, :ip, "$country", "$region", :total]
end
map [:used], [:ippools, :ip, '$country', :used]
map [:total], [:ippools, :ip, '$country', :total]
Expand Down

0 comments on commit 87b7f7e

Please sign in to comment.