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

protected methods #191

Open
mattheworiordan opened this issue Nov 12, 2019 · 3 comments
Open

protected methods #191

mattheworiordan opened this issue Nov 12, 2019 · 3 comments
Labels
enhancement New feature or improved functionality.

Comments

@mattheworiordan
Copy link
Member

mattheworiordan commented Nov 12, 2019

Protected methods are used sparingly, with instead private APIs that need to be public exposed as annotated @private methods (which only affects docs) - see https://github.com/ably/ably-ruby/blob/master/lib/ably/rest/client.rb#L92-L95.

There were reasons at the outset why protected was not used, which I cannot recall. Perhaps backwards compatibility with older versions of Ruby, something I doubt is needed now.

┆Issue is synchronized with this Jira Story by Unito

@mattheworiordan mattheworiordan added the enhancement New feature or improved functionality. label Nov 12, 2019
@TheSmartnik
Copy link
Collaborator

@mattheworiordan could you please clarify what's needed to be done here? Do you want to make private methods marked with@api private?

@mattheworiordan
Copy link
Member Author

See https://github.com/ably/ably-ruby/blob/main/lib/ably/rest/client.rb#L81-L89 for example. These are actually public methods, but only flagged as @private so from a docs perspective they are private. They should instead be protected so that those attributes are not publicly accessible. You may find as you try and change the @private attributes/methods to protected tests may break. You will have to go as far as possible to make as many methods as possible protected and then revisit the ones you could not do to see if this is work worth doing, or accepting some imperfection.

@TheSmartnik
Copy link
Collaborator

@mattheworiordan thanks for the reply. protected makes a method to be accessible inside/by instances of the same class, used for example in (#<=>). So it doesn't really make sense to use it here. Unfortunately, unlike other languages, ruby doesn't have any package/module level visibility modifier. However, I can make a handful of methods/attributes private, but wanted to confirm that we want to proceed in that direction

@sync-by-unito sync-by-unito bot removed the enhancement New feature or improved functionality. label Feb 23, 2023
@lawrence-forooghian lawrence-forooghian added enhancement New feature or improved functionality. code-quality Affects the developer experience when working in our codebase. and removed code-quality Affects the developer experience when working in our codebase. labels Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improved functionality.
Development

No branches or pull requests

3 participants