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

Stabilized toString output for MoneyContext and MoneyNumeric #218

Merged
merged 1 commit into from
Apr 7, 2017

Conversation

garyKeorkunian
Copy link
Contributor

  • Added custom toString methods to MoneyContext and MoneyNumeric to stabilize their output. This should prevent thrash in the README file on each run of tut.

No tests should be required for these methods, as they are primarily used in the REPL and production application code should generally not depend on these values.

@cquiroz
Copy link
Collaborator

cquiroz commented Apr 7, 2017

This looks good, though I'm not sure about the assumption that it wouldn't impact application code. Often code relies on toString for better or worse. Perhaps we should add a note to the Readme/Release notes?

@garyKeorkunian
Copy link
Contributor Author

Yes, I suppose some apps could be using in logs or other ways I've not anticipated. Once it's merged, I'll add a migration note to the release history.

* Custom implementation using SortedSets to ensure consistent output
* @return String representation of this instance
*/
override def toString: String = string
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if we could just map over currencies to get their symbols and make a SortedSet from that. And do the same for rates. That would avoid needing to create Ordering instances for Currency and CurrencyExchangeRate.

Something like:

val cSet = currencies.map { _.code }.sorted.mkString(',')

Copy link
Contributor Author

@garyKeorkunian garyKeorkunian Apr 7, 2017

Choose a reason for hiding this comment

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

Yes, much cleaner. I needed to throw a toSeq call in the pipeline to provide sortability without the Ordering implicit. I'll have a new push soon.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The SortedSet was overkill for the internal implementation, for sure.

@garyKeorkunian garyKeorkunian merged commit ffc4381 into master Apr 7, 2017
@derekmorr derekmorr deleted the fix-money-context-tut branch April 22, 2017 12:56
@cquiroz cquiroz mentioned this pull request May 21, 2017
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.

3 participants