Code Monkey home page Code Monkey logo

Comments (6)

pirj avatar pirj commented on May 23, 2024

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.

AlexWayfer avatar AlexWayfer commented on May 23, 2024

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.

pirj avatar pirj commented on May 23, 2024

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.

AlexWayfer avatar AlexWayfer commented on May 23, 2024

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.

koic avatar koic commented on May 23, 2024

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.

AlexWayfer avatar AlexWayfer commented on May 23, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.