Created
November 2, 2009 17:35
-
-
Save metaskills/224293 to your computer and use it in GitHub Desktop.
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
require 'rubygems' | |
require 'activesupport' | |
class Foo | |
# Mimic Magic | |
cattr_accessor :bar | |
class << self | |
def set_bar(value) | |
@@bar = value | |
end | |
end | |
# User Code | |
bar = :tricked_local_var | |
end | |
Foo.bar # => nil | |
class Foo | |
set_bar :batz | |
end | |
Foo.bar # => :batz | |
class Foo | |
self.bar = :real_class_attr | |
end | |
Foo.bar # => :real_class_attr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment