Class: Ar2gostruct::Builder::ORM::QBS

Inherits:
Base
  • Object
show all
Defined in:
lib/ar2gostruct/builder/orm/qbs.rb

Constant Summary

Constants inherited from Base

Base::TAG_SEPARATOR

Instance Attribute Summary

Attributes inherited from Base

#klass

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Ar2gostruct::Builder::ORM::Base

Instance Method Details

#get_option(col) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ar2gostruct/builder/orm/qbs.rb', line 8

def get_option(col)
  orm_option = []
  # primary key
  if col.name == @klass.primary_key
    orm_option << "pk"
  end
  # not null Constraint
  unless col.null
    orm_option << "notnull"
  end
  # default value
  if col.default
    orm_option << "default:'#{col.default}'"
  end
  # set timestamp
  if col.name == "created_at"
    orm_option << "created"
  elsif col.name == "updated_at"
    orm_option << "updated"
  end
  if orm_option.present?
    return "qbs:\"#{orm_option.join(TAG_SEPARATOR)}\""
  else
    return nil
  end
end