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

Posição de código nas classes #12

Open
aquinofb opened this issue Aug 11, 2015 · 4 comments
Open

Posição de código nas classes #12

aquinofb opened this issue Aug 11, 2015 · 4 comments
Labels

Comments

@aquinofb
Copy link

Sugiro:

class Model
  # extend
  # include
  # accessors
  # hooks
  # associations
  # delegates
  # scopes
  # classMethods
  # instanceMethods
  # protectMethods
  # privateMethods
end
class Controller
  # extend
  # include
  # hooks
  # actionMethods
  # protectMethods
  # privateMethods
end
@aquinofb aquinofb added the ruby label Aug 11, 2015
@fernandodev
Copy link
Contributor

Perfeito -> Ruby Guide

class Person
  # extend and include go first
  extend SomeModule
  include AnotherModule

  # inner classes
  CustomErrorKlass = Class.new(StandardError)

  # constants are next
  SOME_CONSTANT = 20

  # afterwards we have attribute macros
  attr_reader :name

  # followed by other macros (if any)
  validates :name

  # public class methods are next in line
  def self.some_method
  end

  # initialization goes between class methods and other instance methods
  def initialize
  end

  # followed by other public instance methods
  def some_method
  end

  # protected and private methods are grouped near the end
  protected

  def some_protected_method
  end

  private

  def some_private_method
  end
end

@aquinofb
Copy link
Author

Gostei. Achei bem parecido.

@fernandodev
Copy link
Contributor

Gostou pq é bem parecido ou pq é o guia? 😄 hahahaha

@pedromamede
Copy link

Depois do Rails 3.1 é interessante que os hooks venham antes das associations.

Motivo: rubocop/rails-style-guide#77

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

No branches or pull requests

3 participants