Ruby Q? Which style:
def self.method
or
class << self
def method
#ruby #rubyonrails
-
-
@bascule@leshill@jremsikjr for attr_accessor, alias_method, yes, for large numbers of methods, noooooo -
@pjb3@leshill@jremsikjr lol one of the great Ruby holy wars, like Seattle-style parens on defs -
@bascule@pjb3@leshill@jremsikjr I only use "class << self" when no other options are available, clarity level: -10 -
@bascule@pjb3@leshill@jremsikjr Agree with@merbist. -
@davetron5000@pjb3@leshill@jremsikjr@merbist c'mon, class << self is so simple even a baby can understand: http://mislav.uniqpath.com/poignant-guide/images/about.the.poignant.guide-2.jpg … -
@bascule@pjb3@leshill@jremsikjr@merbist it requires too much context to understand code inside it vs. typing 5 characters per method -
@davetron5000@pjb3@leshill@jremsikjr@merbist personally I like the logical grouping it provides and being able to collapse them together -
@bascule@davetron5000@leshill@jremsikjr@merbist once the class << self … end block stretches to longer than a screen, it get's ugly - 6 more replies
New conversation -
-
-
@bascule@leshill@jremsikjr +1, but if you need enough methods for class << self, use a extend ClassMethods -
@bascule@leshill@jremsikjr Or even all three: digging "extend self" there. :) Why decide? -
@judsonlester@leshill@jremsikjr yeah, the instance methods in the module are just shortcuts to the singleton methods in that case
End of conversation
New conversation -
-
-
@jmrtn@isaacsanders@bascule That's my preference. Code for readability rather than foolish consistency. /cc@leshillThanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.