Skip to content

Instantly share code, notes, and snippets.

@metaskills
Created November 2, 2009 17:35
Show Gist options
  • Save metaskills/224293 to your computer and use it in GitHub Desktop.
Save metaskills/224293 to your computer and use it in GitHub Desktop.
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