yabeda icon indicating copy to clipboard operation
yabeda copied to clipboard

Allow Yabeda::Counter#increment to be called without argument

Open goalaleo opened this issue 2 years ago • 2 comments

Hi, this is a small feature request that should be backwards compatible.

Issue

We have some counters in our app that we're not using any tags with. These counters are currently incremented like this

Yabeda.some_counter.increment({})

The increment method has one required positional argument -tags- which has no default value. https://github.com/yabeda-rb/yabeda/blob/ab2be2235253ed6e0d45a4fa97e4decaa32be480/lib/yabeda/counter.rb#L6

Suggestion

Define tags to have a default value of {} so that increment can be called without parentheses

def increment(tags = {}, by: 1)
Yabeda.some_counter.increment

goalaleo avatar May 25 '22 12:05 goalaleo

Hmm. From the one hand sounds reasonable.

From the other – it is quite rare situation when you really need “global” counter without any segmentation. In that case missing required argument tries to remind you that you possibly forget to add tags.

Envek avatar May 25 '22 15:05 Envek

+1 For this. We actually have some global counters where there is no segmentation. Seemed kind of unexpected to have to declare "no tags needed here" explicitly.

chrp avatar Feb 16 '23 08:02 chrp