Shopify / measured

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

Chanage Measured::ConversionTable from a module to a class #107

Closed kmcphillips closed 6 years ago

kmcphillips commented 6 years ago

Problem

The Measured::ConversionTable is built as a module where each method passes in the state.

This is pretty unnecessary. It makes the signatures messy and it's way harder to refactor as I'm trying to do for #103.

Solution

Convert it from a module to a class. Instantiate it and call #to_h. No functional change, just an internal API change.

kmcphillips commented 6 years ago

It's split into a three step refactor, so looking at each commit individually can make it clearer.