class Ar2gostruct::Builder::ORM::GORM

Constants

TAG_SEPARATOR

Public Instance Methods

get_option(col) click to toggle source
   # File lib/ar2gostruct/builder/orm/gorm.rb
10 def get_option(col)
11   orm_option = []
12   # not null Constraint
13   unless col.null
14     orm_option << "not null"
15   end
16   # set size
17   if col.type == :string
18     # SQL type
19     if col.sql_type && /\A\w+\(\d+\)/.match(col.sql_type)
20       orm_option << "type:#{col.sql_type}"
21     end
22     orm_option << "size:#{col.limit}" if col.limit
23   end
24 
25   if orm_option.present?
26     return "sql:\"#{orm_option.join(TAG_SEPARATOR)}\""
27   else
28     return nil
29   end
30 end