Created
September 9, 2011 15:07
-
-
Save acook/1206466 to your computer and use it in GitHub Desktop.
Explanation of some of the internals of ruby.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public # call from anywhere | |
protected # call from inside instance of a class | |
private # only call implicitly from instance | |
Constants # Not inherited, not changed | |
@@class_variables # Inherited, changeable | |
# Changes all sub and super classe as well!! | |
@class_instance_variables # Inherited, changable | |
# Change only the current class, | |
# not sub or super | |
class Array | |
class << self | |
# This is the SINGLTON of Array | |
# singlton classes are the only instance of a given class. | |
attr_accessor :class_instance_variable | |
def class_method | |
end | |
end | |
def public_instance_method | |
self.class.class_instance_variable | |
@@class_variable | |
some_protected_method | |
self.some_protected_method | |
some_private_method | |
# NO self.some_private_method | |
end | |
protected | |
def some_protected_method | |
end | |
private | |
def some_private_method | |
end | |
end | |
# all classes are instances of Class | |
Array.class == Class | |
AnyClass.class == Class |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment