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 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.

nilbus added 3 commits Jul 27, 2015
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

joseph-ravenwolfe commented Jul 27, 2015

👍

@semmons99
Copy link
Member

semmons99 commented Jul 27, 2015

nice!

semmons99 added a commit that referenced this pull request Jul 27, 2015
Allow subclassing money
@semmons99 semmons99 merged commit 6655a38 into RubyMoney:master Jul 27, 2015
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@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

semmons99 commented Jul 27, 2015

6.6.1 released

@nilbus
Copy link
Member Author

nilbus commented Jul 27, 2015

Thanks Shane!​

@Funfun
Copy link
Member

Funfun commented Jul 30, 2015

nice patch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.