Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Counter#decrement #17

Merged
merged 1 commit into from
Sep 11, 2015
Merged

Remove Counter#decrement #17

merged 1 commit into from
Sep 11, 2015

Conversation

grobie
Copy link
Member

@grobie grobie commented Sep 11, 2015

It was decided that counters should always be monotonically increasing,
so we have to remove possibilities to decrement a counter.

Fixes #16.

@jc @juliusv

@@ -11,14 +11,12 @@ def type
end

def increment(labels = {}, by = 1)
fail ArgumentError, 'increment must be a postive integer' if by < 1

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It must be non-negative, 0 and 0.5 are both fine.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm. Right, actually it's about floats (damn untyped languaged). I don't see too much sense in increasing by 0, but fair enough given it's the same as not increasing at all.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@@ -31,6 +31,12 @@
end.to change { counter.get }.by(5)
end

it 'raises an ArgumentError on non-positive increments' do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

non-negative

@brian-brazil
Copy link

👍

There's the odd use case, but it's more for consistency with Summary/Histogram.

It was decided that counters should always be monotonically increasing,
so we have to remove possibilities to decrement a counter.

Fixes #16.
grobie added a commit that referenced this pull request Sep 11, 2015
@grobie grobie merged commit ab2a5e7 into master Sep 11, 2015
@grobie grobie deleted the remove-counter-decrement branch September 11, 2015 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants