Skip to content

Conversation

@seanpdoyle
Copy link

The Comparable#clamp interface supports two additional styles of invocation that Money#clamp does not:

  • a Range instance
  • a nil maximum

To support those invocations, this commit uses the ... argument forwarding syntax to pass along any arguments to the underlying #clamp implementation.

To ensure that the ArgumentError is still raised, this commit introduces test coverage. The prior error's message (min cannot be greater than max) is replaced with the message provided by the standard library (min argument must be less than or equal to max argument).

The [Comparable#clamp][] interface supports two additional styles of
invocation that `Money#clamp` does not:

* a [Range][] instance
* a `nil` maximum

To support those invocations, this commit uses the `...` argument
forwarding syntax to pass along any arguments to the underlying `#clamp`
implementation.

To ensure that the `ArgumentError` is still raised, this commit
introduces test coverage. The prior error's message (`min cannot be
greater than max`) is replaced with the message provided by the standard
library (`min argument must be less than or equal to max argument`).

[Comparable#clamp]: https://docs.ruby-lang.org/en/master/Comparable.html#method-i-clamp
[Range]: https://docs.ruby-lang.org/en/master/Range.html
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.

1 participant