Sha256: 731f7758681d61f595779f9831a0fd2433e44b0cd8d79bcc7dc8dd89e73f352f
Contents?: true
Size: 1.29 KB
Versions: 1
Compression:
Stored size: 1.29 KB
Contents
module Arql class Definition class << self def models @@models ||= [] end end def initialize @@models = [] ActiveRecord::Base.connection.tap do |conn| conn.tables.each do |table_name| conn.primary_key(table_name).tap do |pkey| table_name.camelize.tap do |const_name| const_name = 'Modul' if const_name == 'Module' const_name = 'Clazz' if const_name == 'Class' Class.new(ActiveRecord::Base) do self.primary_key = pkey self.table_name = table_name self.inheritance_column = nil self.default_timezone = :local end.tap do |clazz| Object.const_set(const_name, clazz).tap do |const| const_name.gsub(/[a-z]*/, '').tap do |abbr| unless Object.const_defined?(abbr) Object.const_set abbr, const abbr_const = abbr end @@models << { model: const, abbr: abbr_const, table: table_name } end end end end end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
arql-0.1.4 | lib/arql/definition.rb |