Skip to content

Instantly share code, notes, and snippets.

@ivanyv
Last active December 30, 2015 00:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivanyv/7753638 to your computer and use it in GitHub Desktop.
Save ivanyv/7753638 to your computer and use it in GitHub Desktop.
Crazy global variables
require 'singleton'
class G
include Singleton
attr_accessor :variables
def self.[](var)
variables[var]
end
def self.[]=(var, value)
variables[var] = value
end
private
def self.variables
instance.variables ||= {}
end
end
require 'globals'
G[:wat] = 'that'
G[:wat] # == 'that'
@ivanyv
Copy link
Author

ivanyv commented Dec 2, 2013

Got carried away improving and refactoring this useless "feature" :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment