Sha256: 67ea21de966ecc2534b3c9af1fa7e09d772237f39cb756d44812c6d8d8124378
Contents?: true
Size: 956 Bytes
Versions: 2
Compression:
Stored size: 956 Bytes
Contents
module DrNicMagicModels class Schema class << self def models @@models ||= nil load_schema if @@models.blank? @@models end def reset @@models = nil end def load_schema if conn = ActiveRecord::Base.connection @@models = DrNicMagicModels::ModelHash.new @@models.merge! conn.tables.inject({}) {|model_list,table_name| model_list[ActiveRecord::Base.class_name(table_name)] = table_name; model_list} end end end end class ModelHash < Hash def unenquire(class_id) @enquired ||= {} @enquired[class_id = class_id.to_s] = false end def enquired?(class_id) @enquired ||= {} @enquired[class_id.to_s] end def [](class_id) enquired?(class_id = class_id.to_s) @enquired[class_id] = true super(class_id) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dr_nic_magic_models-0.7.1 | lib/dr_nic_magic_models/schema.rb |
dr_nic_magic_models-0.7.0 | lib/dr_nic_magic_models/schema.rb |