There are 3 ways to create class methods in ruby:
Probably when you just need one1
2
3
4
5
6
7
| class Thing
def self.all
:everything
end
end
Thing.all # >> :everything
|
Probably when you need several1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| class Thing
class << self
def self.all
:everything
end
def self.some
:something
end
end
end
Thing.all # >> :everything
Thing.some # >> :something
|
Probably when you are going bananas1
2
3
4
5
6
7
| class Thing
def Thing.all
:everything
end
end
Thing.all # >> :everything
|
If you work with me & u use the last one, i’ll hunt u down &
haunt you :P