D
Douglas Livingstone
class MyClass
def self.do_something
puts 'success'
end
do_something
end
This puts 'success' - this is a a class method right?
How do I move the "def self..end" section into a module? Trying the obvious:
module MyModule
def self.do_something
puts 'success'
end
end
class MyClass
include MyModule
do_something
end
doesn't seem to work, but this does:
module MyModule
def do_something
puts 'success'
end
end
class MyClass
include MyModule
def ex
do_something
end
end
MyClass.new.ex
Here, is "run" an instance method, which is why it can only be called
from a #new instance? How do I get it to get called from this:
class MyClass
include MyModule
do_something
end
Thanks,
Douglas
def self.do_something
puts 'success'
end
do_something
end
This puts 'success' - this is a a class method right?
How do I move the "def self..end" section into a module? Trying the obvious:
module MyModule
def self.do_something
puts 'success'
end
end
class MyClass
include MyModule
do_something
end
doesn't seem to work, but this does:
module MyModule
def do_something
puts 'success'
end
end
class MyClass
include MyModule
def ex
do_something
end
end
MyClass.new.ex
Here, is "run" an instance method, which is why it can only be called
from a #new instance? How do I get it to get called from this:
class MyClass
include MyModule
do_something
end
Thanks,
Douglas