Skip to content

Commit

Permalink
Fix defaults handling in increment/3 and decrement/3
Browse files Browse the repository at this point in the history
  • Loading branch information
lexmag committed Nov 12, 2016
1 parent b94b483 commit 6f119ff
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/statix.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ defmodule Statix do
:ok
end

def increment(key, val \\ "1", options \\ []) do
def increment(key, val \\ 1, options \\ []) when is_number(val) do
Statix.transmit(@statix_conn, :counter, key, val, options)
end

def decrement(key, val \\ "1", options \\ []) do
def decrement(key, val \\ 1, options \\ []) when is_number(val) do
Statix.transmit(@statix_conn, :counter, key, [?-, to_string(val)], options)
end

Expand Down Expand Up @@ -52,7 +52,8 @@ defmodule Statix do
end
end

def transmit(conn, type, key, val, options \\ []) when is_binary(key) or is_list(key) do
def transmit(conn, type, key, val, options \\ [])
when (is_binary(key) or is_list(key)) and is_list(options) do
if Keyword.get(options, :sample_rate, 1.0) >= :rand.uniform() do
Statix.Conn.transmit(conn, type, key, to_string(val), options)
else
Expand Down

0 comments on commit 6f119ff

Please sign in to comment.