Ruby Object Model

In Ruby Everything is object. We will see “class” objects. “class” objects are instance of “class Class” which inherits from “class Module” which inherits from “class Object” which mixins with “module Kernel” class objects can be created in two ways Conventional way class Samba attr_accessor :a, :b def Samba.classmethod end def instancemethod end end Actually this is what happening at the time of execution Samba = Samba.attr_accessor :a, :b Samba.class_eval do def classmethod end end Samba.instance_eval do def instance_method end end As Samba is instance of “class Class”, all the public, protected “instance members” of Class, Module, Object, Kernel are available to object Samba Samba is also class, which implicitly inherits from “class Object” x = Now x has access to public and protected instance member of Object and Kernel


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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s