Ruby Object Model Contd

We will look at “module” objects. “module” objects are instances of “class Module” which inherits from “class Object”. Like “class” objects “module” objects can be created in two ways module Samba CONST = 1 def Samba.module_method end def instance_method end end This is what happening at the time of execution Samba = Samba.module_eval do def module_method end end Samba.instance_eval do def instance_method end end “module” objects can be used in two ways. 1. “class” objects can “include” “module” objects, then module object become immediate ancestor to “class” objects. That means “module” object is inserted between “class” and “Object” in hierarchy. 2. Any object can “extend” module. That means all the consts and instace methods of module are available to object

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s