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

Private methods indentation #10

Open
dzhlobo opened this issue Apr 22, 2013 · 5 comments
Open

Private methods indentation #10

dzhlobo opened this issue Apr 22, 2013 · 5 comments

Comments

@dzhlobo
Copy link
Contributor

dzhlobo commented Apr 22, 2013

We should discuss code convention about indentation private methods in classes. We have two common conventions.

First one:

class Foo
  def public_method
  end

  private

    def private_method
    end
end

Second one:

class Bar
  def public_method
  end

private

  def private_method
  end
end

Also I propose to add one blank line before private word and one after.

@dzhlobo
Copy link
Contributor Author

dzhlobo commented Apr 22, 2013

@gotva, @FoboCasteR, @jaturken what do you think about this?

I personally prefer second variant but have no arguments.

@FoboCasteR
Copy link
Contributor

@gotva
Copy link
Contributor

gotva commented Apr 22, 2013

I prefer

class Foo
  class << self
    def method_of_class
    end
  end

  def instance_method
  end

  private # or protected

    def private_method
    end

end

I prefer to have more than 2 spaces in any not public-instance methods. When you open a model with 100+ lines you go to the end of file and start writing code it can be wrong place for your code (it can be private/protected section). If you have convention described above you will see 4 spaces before definition and it is a sign that it is not correct place for your code

@FoboCasteR
Copy link
Contributor

@jaturken
Copy link
Contributor

@FoboCasteR 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants