Class: Phoenix::Base

Inherits:
Object
  • Object
show all
Includes:
Common
Defined in:
lib/phoenix/base.rb

Class Method Summary collapse

Methods included from Common

#error, #human_create_date, #human_status, #initialize

Class Method Details

.inherited(base) ⇒ Object

类变量meta_data 记录表的字段类型 [:column_type=>“UNSIGNED_INT”,

{:column_name=>"ACCOUNT_ID", :column_type=>"VARCHAR"},  
{:column_name=>"CREATE_DATE", :column_type=>"UNSIGNED_LONG"}]


10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/phoenix/base.rb', line 10

def self.inherited(base)
  table_name = base.table_name
  meta = Phoenix::Rjb.(table_name)
  if meta.blank?
    raise "the phoenix table #{table_name} is Not Found!!!"
  end
  base.class_variable_set("@@meta_data", meta)

  meta.each do |row|
    base.send(:attr_accessor, row[:column_name])
  end
end