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

Allow subclassing money #544

Merged
merged 3 commits into from Jul 27, 2015
Merged

Conversation

nilbus
Copy link
Member

@nilbus nilbus commented Jul 27, 2015

I can see from the spec previously included that it was desired that subclassing would work, but the implementation was incomplete.

Scenario:

class SpecialMoney < Money
  # ...
end

SpecialMoney.new(val1) + SpecialMoney.new(val2)
# => returns Money instead of SpecialMoney, thus losing the
# SpecialMoney extensions.

All specs remain green, and it works as expected. New specs have been added to attempt to prevent regression.

Scenario:

    class SpecialMoney < Money
      # ...
    end

    SpecialMoney.new(val1) + SpecialMoney.new(val2)
    # => returns Money instead of SpecialMoney, thus losing the
    # SpecialMoney extensions.
Currency#inspect is also defined but already does this.
Method calls on a subclass of Money should never return a Money object.
@joseph-ravenwolfe
Copy link

👍

@semmons99
Copy link
Member

nice!

semmons99 added a commit that referenced this pull request Jul 27, 2015
@semmons99 semmons99 merged commit 6655a38 into RubyMoney:master Jul 27, 2015
@nilbus
Copy link
Member Author

nilbus commented Jul 27, 2015

Thanks for the quick response! If you could release this quickly, that would be helpful to myself and @josephjaber. I believe this would qualify as a patch release (6.6.1), as it seems like a fix to something that was already intended. What do you think?

@semmons99
Copy link
Member

6.6.1 released

@nilbus
Copy link
Member Author

nilbus commented Jul 27, 2015

Thanks Shane!​

@tsyber1an
Copy link
Member

nice patch

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.

None yet

4 participants