Class: MigrationDefs::ColumnOption
- Inherits:
-
AbstractMigrationClass
- Object
- AbstractMigrationClass
- MigrationDefs::ColumnOption
- Defined in:
- lib/migration_defs.rb
Constant Summary collapse
- Description =
{ 'limit' => 'カラムの桁数', 'default' => 'デフォルトの値', 'null' => 'nullを許可するか', 'precision' => '数値の桁数', 'scale' => '小数点以下の桁数', }
Instance Attribute Summary collapse
-
#default ⇒ Object
Returns the value of attribute default.
-
#limit ⇒ Object
Returns the value of attribute limit.
-
#null ⇒ Object
Returns the value of attribute null.
-
#precision ⇒ Object
Returns the value of attribute precision.
-
#scale ⇒ Object
Returns the value of attribute scale.
Instance Method Summary collapse
- #get_str ⇒ Object
-
#initialize(limit = nil, default = nil, is_null = false, precision = nil, scale = nil) ⇒ ColumnOption
constructor
A new instance of ColumnOption.
Constructor Details
#initialize(limit = nil, default = nil, is_null = false, precision = nil, scale = nil) ⇒ ColumnOption
Returns a new instance of ColumnOption.
168 169 170 171 172 173 174 |
# File 'lib/migration_defs.rb', line 168 def initialize(limit = nil, default = nil, is_null = false, precision = nil, scale = nil) @limit = limit @default = default @null = is_null @precision = precision @scale = scale end |
Instance Attribute Details
#default ⇒ Object
Returns the value of attribute default.
158 159 160 |
# File 'lib/migration_defs.rb', line 158 def default @default end |
#limit ⇒ Object
Returns the value of attribute limit.
158 159 160 |
# File 'lib/migration_defs.rb', line 158 def limit @limit end |
#null ⇒ Object
Returns the value of attribute null.
158 159 160 |
# File 'lib/migration_defs.rb', line 158 def null @null end |
#precision ⇒ Object
Returns the value of attribute precision.
158 159 160 |
# File 'lib/migration_defs.rb', line 158 def precision @precision end |
#scale ⇒ Object
Returns the value of attribute scale.
158 159 160 |
# File 'lib/migration_defs.rb', line 158 def scale @scale end |
Instance Method Details
#get_str ⇒ Object
176 177 178 179 180 181 182 183 184 |
# File 'lib/migration_defs.rb', line 176 def get_str result = '' result += ", :limit => #{@limit.to_s}" if !@limit.blank? && @limit != 0 result += ", :default => #{@default.to_s}" if !@default.blank? result += ", :null => #{@null.to_s}" if !@null.blank? result += ", :precision => #{@precision.to_s}" if !@precision.nil? && @precision != 0 result += ", :scale => #{@scale.to_s}" if !@scale.nil? && @scale != 0 result end |