-
Notifications
You must be signed in to change notification settings - Fork 23
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
values: prepend superclass values #29
Conversation
When enumerating values for a subclass, the superclass values are prepended. Fixes #27.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
- update CHANGELOG
- bump version to 0.9.0
- document values behavior in README
The spec file violates the Metrics/BlockLength cop and always needs to be updated. This excludes the file from being evaluated against that rule so that other blocks may still adhere to a normal block length configuration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- increment version in version.rb
- I think because we're changing behavior here in significant ways, I think we need an UPGRADING file, ala https://github.com/slack-ruby/slack-ruby-client/blob/master/UPGRADING.md
More comments below.
Could this just go into the changelog? I worry that the UPGRADING file is going to look exactly like the CHANGELOG. Perhaps, for this simple case, a "Breaking Changes" section in the changelog version's entry? What did you have in mind for the content? |
This is more of a convention thing from dozens of projects - sometimes these get very long and full of before/after examples, so we haven't been putting long explanations about upgrading into changelog.
I think something like enum classes now inherit values, for example ... with before: and after: output. Keep the format similar to the UPGRADING.md I linked (thank you) |
define :BLUE, 'BLUE' | ||
end | ||
|
||
class RainbowColors < PrimaryColors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example is super clear, this works.
I do have a question. In the scenario with colors inheritance is the wrong object oriented pattern to use. Rainbow colors don't "inherit" primary colors, they are a combination of primary colors and other colors. In this case we would want a module and mixins. Should we allow class PrimaryColors
be module PrimaryColors
, extend Ruby::Enum
, then include PrimaryColors
into RainbowColors
or something like that? ... for another PR.
Maybe there's a better OOO example for README that we can use in a separate update? WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. Semantically, it makes more sense to include
the PrimaryColors
in the RainbowColors
class instead of inheriting them.
Though, I see this is a minor implementation detail. Defining an enum doesn't actually create an instance of that class: Colors::RED
isn't an instance of Ruby::Enum
or Colors
. It's a String
or Symbol
.
There's little difference between inheriting from a class and including a module other than the Ruby semantics. Both options include the base/included class in the class hierarchy.
Regardless, I think this could be an update for another PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
100%
Merged, thank you! Do you want to help out with maintenance of this gem @gi? Maybe make the next release. If yes, email dblock[at]dblock[dot]org with your rubygems username/email and I'll add you. |
When enumerating values for a subclass, the superclass values are prepended.
Fixes #27.