Skip to content

Extending existing measurements #11

@MyklClason

Description

@MyklClason

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.

@unit = Unit.new(unit_name)

@unit = Unit.new(unit_name)

Thoughts?

Does that seem reasonable?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions