Skip to content

Instantly share code, notes, and snippets.

/ruby.rb Secret

Created November 3, 2016 23:24
Show Gist options
  • Save anonymous/44a631e209abe5b1ede27a8a47e55e19 to your computer and use it in GitHub Desktop.
Save anonymous/44a631e209abe5b1ede27a8a47e55e19 to your computer and use it in GitHub Desktop.
# Class to model reference
# so we can get back to the class that represents the model
class ModelRefContainer
@@hashTable = Hash.new
def self.insert(modelRef, classRef)
@@hashTable[modelRef] = classRef
end
def self.getClass(modelRef)
value = @@hashTable[modelRef]
return value
end
def self.getModel(classRef)
key = @@hashTable.key(classRef)
return key
end
def self.showKeys
puts @@hashTable.keys
end
def self.showValues
puts @@hashTable.values
end
def self.hasModel(modelRef)
return @@hashTable.key?(modelRef)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment