Comments (6)
Are refinements a feature sufficiently used to be mentioned?
At a glance, I could find this.
Can you find more in e.g. real-world-ruby-apps
?
from ruby-style-guide.
Are refinements a feature sufficiently used to be mentioned? At a glance, I could find this. Can you find more in e.g.
real-world-ruby-apps
?
I don't know about "real world apps" repos, to be honest.
Some backstory, probably…
I had a pretty difficult discussion a few years ago about prepend
, which I liked that time. And my colleague has been referenced to this guide, that any prepend
should be placed at the top of class definition, as well as include
. There are confusions about public
vs. private
, if I place include
(or prepend
or using
) under private
— are public methods from joined module are private? Answer — no, but prepend
is more complicated anyway.
So… I've seen a Twitter thread about ActiveSupport vs. refinements and remembered my own gem: https://twitter.com/soulcutter/status/1572578613471608834
And today I've been working on my (open-source) project after a long time, and this question about public-private popped up in my head again, and I've decided to check the Ruby Style Guide and found no answer to this.
During using
works as well as include
or prepend
, I mean ignore placement under private
or protected
, I believe we should mention it among other keywords in the guide.
Don't you think so?
from ruby-style-guide.
Please don't get me wrong, I'm all for AS to be reworked to be less intrusive, with refinements or else.
Putting include
under method visibility modifiers is covered by the before mentioned guideline, even though there is no explanation in the guideline that including a module under private
won't make methods private.
I'm only questioning the existence of real-life usage of refinements, considering this:
A style guide that reflects real-world usage gets used
The style guide is not trying to be a definitive language guide, and is covering common mistakes and common good practices.
from ruby-style-guide.
The style guide is not trying to be a definitive language guide, and is covering common mistakes and common good practices.
OK: without a real-life apps (I can provide you one, but it's only one, I don't know fans of this approach, and I don't want to make "an ad" for it), how do you think: using using
under private
is a good practice? Or it worth to place it at the top of class definition?
from ruby-style-guide.
using
is a special file scope that behaves differently depending on where it is used. I think it should not be covered in "Consistent Classes" section.
rubocop/rubocop#10837 (comment)
from ruby-style-guide.
using
is a special file scope that behaves differently depending on where it is used. I think it should not be covered in "Consistent Classes" section. rubocop/rubocop#10837 (comment)
Interesting, didn't know this (or forgot). Thank you, then I guess we should close this issue…
from ruby-style-guide.
Related Issues (20)
- Typo in loop with break? HOT 1
- New exception classes HOT 1
- File naming with acronyms HOT 3
- `extend`ing objects at runtime HOT 2
- Usage of do...end block syntax in conditionals HOT 1
- Compact case statements: is there a way to enforce single-line when? HOT 4
- Add a rule for method calls in multiline blocks HOT 3
- Good practice - Heredocs in hash HOT 2
- Whitespace around certain operators HOT 6
- Prefer `grep` and `grep_v` to `select`/`reject` that does a regexp match (Ruby 3+)
- Numbered parameters HOT 2
- Is there a typo in the Suppressing Exceptions section? HOT 2
- Add guidance for safe navigation operator (`&.`) HOT 3
- Why not allowing multi-line ternary operator? HOT 2
- The '%w' and '%i' syntax for arrays is just a bad idea HOT 10
- Consider definining `#nil?` method a bad practice HOT 4
- Enforce no parentheses for `include`, `extend`, etc?
- [Idea] Write "good" before "bad" examples HOT 2
- /.,m/.,m/.,m/.,m./,m.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ruby-style-guide.