Skip to content

Instantly share code, notes, and snippets.

@anewusername1
Created June 17, 2011 15:11
Show Gist options
  • Save anewusername1/1031615 to your computer and use it in GitHub Desktop.
Save anewusername1/1031615 to your computer and use it in GitHub Desktop.
Unfickle Blog Post
class SomeClass
SOMECONSTANT = 'somevalue'
...
end
class SomeClass
set_const :someconstant, 'somevalue'
end
> SomeClass::SOMECONSTANT
=> 'somevalue'
> SomeClass.keys
=> [:SOMECONSTANT]
gem install unfickle
module Unfickle
extend Forwardable
def set_const(key,value)
@hash ||= {}
@hash[key.upcase.to_sym]=value
end
def const_missing(key)
@hash[key]
end
def_delegators :@hash, :each, :values, :keys, :[]
def clear
@hash = {}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment