Created
August 11, 2011 16:44
-
-
Save corntrace/1140134 to your computer and use it in GitHub Desktop.
Class variable overwrite in inheritance
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
class BaseKlass | |
cattr_accessor :map | |
end | |
class KlassA < BaseKlass | |
self.map = {:a => 1, :b => 2} | |
end | |
class KlassB < BaseKlass | |
self.map = {:c => 3, :d => 4} | |
end | |
KlassA.map # => {:c => 3, :d => 4} ! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment