- Google+ Tools
-
Make Google+ profile picture
Make Google plus banners for profile
Create and share your Google Plus profile banners.
There are two ways to insert a module above the objects singleton class but before the objects Class
Mixing in a Module immediately after an objects Singleton class
#You can open the class definition body of a singleton class and add instance methods, class methods, and constants
#You do this by using the 'class' keyword and a CONSTANT
class C
def hello
puts "this is a hello yo."
end
end
module M
def talk
puts "hello."
end
end
#Example 1
example1 = C.new
class << example1
include M
end
#Call the Singleton method
example1.hello
#Call the Module Mix-in
example1.talk
#Example 2
example2 = C.new
example2.extend(M)
example2.talk
Comments
blog comments powered by Disqus