easierbycode
2/29/2012 - 3:22 AM

Class vs Instance methods - when to use self.some_method

Class vs Instance methods - when to use self.some_method

# http://bagwanpankaj.com/metaprogramming-in-rails

class Testt

end

Testt.class_eval do
  def foo
    "I'll be available as instance method"
  end

  def self.foo
    "I'll be available as class method"
  end
end

Testt.new().foo
=> "I'll be available as instance method"
Testt.foo
=>"I be available as class method"