You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Decided to make an issue out PR #8 (comment). Summa, was I wanted to discuss how to go about extending the code. Anyone is free to write the code themselves, I just wanted to think a bit on how to go about it in case I have a need to implement it.
After reviewing the code for a bit, it seems like the key is to slightly re-configure how the Builder class works. Looks like the easy way is to change how builder initialize works, so that it can use an existing unit rather than creating a new one. Measurement.extend would then use this alternative approach to extend the existing unit rather than overwrite it.
Specifically this line of code would need to be changed in the Builder class to some sort of lookup to check if the unit already exists. Sadly, my Ruby knowledge is a bit lacking as to how exactly to go about it.
One benefit of that change too is that you would no longer need to define a new extend method, but could just reuse the define method to append new info to a unit.
Decided to make an issue out PR #8 (comment). Summa, was I wanted to discuss how to go about extending the code. Anyone is free to write the code themselves, I just wanted to think a bit on how to go about it in case I have a need to implement it.
After reviewing the code for a bit, it seems like the key is to slightly re-configure how the
Builder
class works. Looks like the easy way is to change how builderinitialize
works, so that it can use an existing unit rather than creating a new one.Measurement.extend
would then use this alternative approach to extend the existing unit rather than overwrite it.Specifically this line of code would need to be changed in the Builder class to some sort of lookup to check if the unit already exists. Sadly, my Ruby knowledge is a bit lacking as to how exactly to go about it.
ruby-measurement/lib/ruby-measurement/unit.rb
Line 73 in a8627b3
Thoughts?
Does that seem reasonable?
The text was updated successfully, but these errors were encountered: