Further to this:

I know it seems counter-intuitive, but the private keyword (at least, when used 
as a keyword rather than a method) doesn’t have any impact on class-level 
methods. As far as I know, this has always been the way Ruby behaves.

I used to find this annoying, but now I take it as a suggestion that the 
(public) class method that makes calls out to other methods that you’d normally 
have marked as private, should instead create an instance of a class, and that 
instance can then have public and private methods as required to do the 
necessary work.

Completely unrelated: Tom, I know you posted twice about this, I’m generally 
the one looking after the list moderation, and I saw the first and let it 
through before I saw the second, which I have kept back to avoid duplication. 
Most posts are moderated on this list to keep things reasonably on topic (also 
to keep the job posts following the guidelines).

Cheers

— 
Pat

> On 7 Jan 2016, at 8:08 PM, Jon Rowe <[email protected]> wrote:
> 
> `private` and `private_class_method` aren’t just keywords, they take 
> arguments e.g.
> 
> private :method_name
> private_class_method :class_method_name
> 
> that will work consistently… I’ve never seen `private_class_method def 
> self.class_method_name` in the wild I suspect that it only works by accident… 
> 
> Jon Rowe
> ---------------------------
> [email protected]
> jonrowe.co.uk
> 
> On Thursday, 7 January 2016 at 19:47, Ravi (Tom) Hale wrote:
> 
>> I'm trying to wrap my head around this seeming inconsistency.
>> 
>> Tested with Ruby 2.2.3
>> 
>> On a line by itself
>> -------------------
>> private - makes all following definitions private
>> private_class_method - *does nothing* - following methods are still
>> available publicly
>> 
>> On the same line as a method definition
>> ---------------------------------------
>> private - fails: `private def self.priv`: test.rb:32:in `private':
>> undefined method `priv' for class `Self' (NameError)
>> private_class_method - works (with def self.methodname)
>> 
>> Can anyone help out?
>> 
>> If you too think it is worth reporting to the ruby developers, how would
>> I best go about informing them?
>> 
>> Cheers,
>> Tom
>> 
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Ruby or Rails Oceania" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] 
>> <mailto:[email protected]>.
>> To post to this group, send email to [email protected] 
>> <mailto:[email protected]>.
>> Visit this group at https://groups.google.com/group/rails-oceania 
>> <https://groups.google.com/group/rails-oceania>.
>> For more options, visit https://groups.google.com/d/optout 
>> <https://groups.google.com/d/optout>.
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby or Rails Oceania" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] 
> <mailto:[email protected]>.
> To post to this group, send email to [email protected] 
> <mailto:[email protected]>.
> Visit this group at https://groups.google.com/group/rails-oceania 
> <https://groups.google.com/group/rails-oceania>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
or Rails Oceania" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/rails-oceania.
For more options, visit https://groups.google.com/d/optout.

Reply via email to