Class: MigrationDefs::CreateTableOption
- Inherits:
-
AbstractMigrationClass
- Object
- AbstractMigrationClass
- MigrationDefs::CreateTableOption
- Defined in:
- lib/migration_defs.rb
Constant Summary collapse
- Description =
{ 'id' => '主キーを自動生成', 'primary_key' => '主キーのカラムの名前', 'options' => 'テーブルオプション', 'temporary' => '一時テーブルとして作成', 'force' => 'テーブルを作成前に、既存のテーブルを削除', }
Instance Attribute Summary collapse
-
#force ⇒ Object
Returns the value of attribute force.
-
#id ⇒ Object
Returns the value of attribute id.
-
#options ⇒ Object
Returns the value of attribute options.
-
#primary_key ⇒ Object
Returns the value of attribute primary_key.
-
#temporary ⇒ Object
Returns the value of attribute temporary.
Instance Method Summary collapse
- #get_str ⇒ Object
-
#initialize(id = true, primary_key = 'id', options = nil, temporary = false, force = false) ⇒ CreateTableOption
constructor
A new instance of CreateTableOption.
- #set_option(key, val) ⇒ Object
Constructor Details
#initialize(id = true, primary_key = 'id', options = nil, temporary = false, force = false) ⇒ CreateTableOption
Returns a new instance of CreateTableOption.
231 232 233 234 235 236 237 |
# File 'lib/migration_defs.rb', line 231 def initialize(id = true, primary_key = 'id', = nil, temporary = false, force = false) @id = id @primary_key = primary_key @options = @temporary = temporary @force = force end |
Instance Attribute Details
#force ⇒ Object
Returns the value of attribute force.
221 222 223 |
# File 'lib/migration_defs.rb', line 221 def force @force end |
#id ⇒ Object
Returns the value of attribute id.
221 222 223 |
# File 'lib/migration_defs.rb', line 221 def id @id end |
#options ⇒ Object
Returns the value of attribute options.
221 222 223 |
# File 'lib/migration_defs.rb', line 221 def @options end |
#primary_key ⇒ Object
Returns the value of attribute primary_key.
221 222 223 |
# File 'lib/migration_defs.rb', line 221 def primary_key @primary_key end |
#temporary ⇒ Object
Returns the value of attribute temporary.
221 222 223 |
# File 'lib/migration_defs.rb', line 221 def temporary @temporary end |
Instance Method Details
#get_str ⇒ Object
254 255 256 257 258 259 260 261 262 |
# File 'lib/migration_defs.rb', line 254 def get_str result = '' result += ", :id => #{@id.to_s}" if !@id.nil? && !@id result += ", :primary_key => #{@primary_key}" if @primary_key != 'id' result += ", :options => #{@options}" if !@options.nil? && !@options.blank? result += ", :temporary => #{@temporary.to_s}" if !@temporary.nil? && @temporary != false result += ", :force => #{@force.to_s}" if !@force.nil? && @force != true result end |
#set_option(key, val) ⇒ Object
239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
# File 'lib/migration_defs.rb', line 239 def set_option(key, val) case key when 'id' @id = (val == 'true') when 'primary_key' @primary_key = val when 'options' @options = val when 'temporary' @temporary = (val == 'true') when 'force' @force = (val == 'true') end end |