Shopify / measured

Encapsulate measurements and their units in Ruby and Ruby on Rails.
MIT License
362 stars 28 forks source link

Allow unit values to be defined as aliases and not only the base unit #128

Closed kmcphillips closed 4 years ago

kmcphillips commented 4 years ago

As described in #127 @trcarden, defining the value of a unit using an alias raises.

This happens because we don't have the UnitSystem defined yet that can look up the aliases. It's a chicken egg problem.

So we do the search manually in this case, rather than error. It's not a huge amount of effort, with a little duplication.

I've refactored the with( method to maintain immutability of Unit.

kmcphillips commented 4 years ago

Closes #127

kmcphillips commented 4 years ago

I'll have to fiddle with CI. And there's some unreleated deprecations I'll fix in this release too.