bbatsov/ruby-style-guide — pull request #62 by nilbus (2011-11-11 18:19:05+00:00)
Title: Outdent public, protected, and private keywords.

This has been discussed previously in #31, but I much disagree with the
stance that was decided on. I want to open this up again for discussion.

The problem with having private in line with the method definitions is
that it goes unnoticed. There's no clear distinction between public and
private methods. It may not be so obvious here, but it's a lot more
important when your classes are hundreds of lines long.

class class Foo
def bar
end

private
def baz
end
end

Outdent style, on the other hand, is quite visible and easy to read.
It's not semantically correct, but it's very similar to other similar
constructs that make sections of code. While `private` is technically a
method call, it acts to section off code, just like if/else and
begin/rescue. @burke is correct in #31 that it does not open a new
scope, but that hardly matters in the context of a class definition.
Similarly with a begin/rescue block, code in the rescue block can still
reference variables created in the begin section.

if
foo
else
bar
end

begin
foo
rescue
bar
end

class Foo
def bar
end

private
def baz
end
end

Finally, although no project's style stands as law, the Rails source has
certainly been the most influential in the Ruby community for setting
standards for code style. Much of their new code now uses the style I'm
suggesting.

For reference, this article talks about the pros and cons of each style.
http://fabiokung.com/2010/04/05/ruby-indentation-for-access-modifiers-and-their-sections/