Sha256: cf654fa57e29d849bce825dd9aa4c936ade014cc3a3907cc2224c5f5b985fcae

Contents?: true

Size: 549 Bytes

Versions: 2

Compression:

Stored size: 549 Bytes

Contents

class Module
  alias :normal_const_missing :const_missing
  
  def const_missing(class_id)
    begin
      return normal_const_missing(class_id)
    rescue
    end
    unless table_name = DrNicMagicModels::Schema.models[class_id]
      raise NameError.new("uninitialized constant #{class_id}") if DrNicMagicModels::Schema.models.enquired? class_id
    end
    klass_code = lambda {klass_code}
    klass = Class.new ActiveRecord::Base, &klass_code
    const_set class_id, klass
    klass.set_table_name table_name
    klass
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dr_nic_magic_models-0.7.1 lib/module.rb
dr_nic_magic_models-0.7.0 lib/module.rb