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

Conversation

Projects
None yet
4 participants
@nilbus
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 some commits Jul 27, 2015

Support subclassing of Money by never instantiating it by name
Scenario:

    class SpecialMoney < Money
      # ...
    end

    SpecialMoney.new(val1) + SpecialMoney.new(val2)
    # => returns Money instead of SpecialMoney, thus losing the
    # SpecialMoney extensions.
Report the actual class in Money#inspect
Currency#inspect is also defined but already does this.
Expand inheritance tests to all the methods that handle it
Method calls on a subclass of Money should never return a Money object.
@josephjaber

This comment has been minimized.

Show comment
Hide comment

👍

@semmons99

This comment has been minimized.

Show comment
Hide comment
@semmons99

semmons99 Jul 27, 2015

Member

nice!

Member

semmons99 commented Jul 27, 2015

nice!

semmons99 added a commit that referenced this pull request Jul 27, 2015

@semmons99 semmons99 merged commit 6655a38 into RubyMoney:master Jul 27, 2015

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@nilbus

This comment has been minimized.

Show comment
Hide comment
@nilbus

nilbus Jul 27, 2015

Member

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?

Member

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

This comment has been minimized.

Show comment
Hide comment
@semmons99

semmons99 Jul 27, 2015

Member

6.6.1 released

Member

semmons99 commented Jul 27, 2015

6.6.1 released

@nilbus

This comment has been minimized.

Show comment
Hide comment
@nilbus

nilbus Jul 27, 2015

Member

Thanks Shane!​

Member

nilbus commented Jul 27, 2015

Thanks Shane!​

@Funfun

This comment has been minimized.

Show comment
Hide comment
@Funfun

Funfun Jul 30, 2015

Member

nice patch

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