Class: ActiveRecordMigrationTableMock
- Inherits:
-
Object
- Object
- ActiveRecordMigrationTableMock
- Defined in:
- lib/sixarm_ruby_active_record_migration_mock/active_record_migration_table_mock.rb
Instance Attribute Summary collapse
-
#columns ⇒ Object
Returns the value of attribute columns.
-
#indexes ⇒ Object
Returns the value of attribute indexes.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #column(column_name, column_type, column_options = {}) ⇒ Object
- #has_column?(column_name) ⇒ Boolean
- #has_index?(column_name) ⇒ Boolean
- #index(column_name) ⇒ Object
-
#initialize(name) ⇒ ActiveRecordMigrationTableMock
constructor
A new instance of ActiveRecordMigrationTableMock.
- #to_s ⇒ Object
Constructor Details
#initialize(name) ⇒ ActiveRecordMigrationTableMock
Returns a new instance of ActiveRecordMigrationTableMock.
8 9 10 11 12 |
# File 'lib/sixarm_ruby_active_record_migration_mock/active_record_migration_table_mock.rb', line 8 def initialize(name) @name = name @columns = {} @indexes = {} end |
Instance Attribute Details
#columns ⇒ Object
Returns the value of attribute columns.
5 6 7 |
# File 'lib/sixarm_ruby_active_record_migration_mock/active_record_migration_table_mock.rb', line 5 def columns @columns end |
#indexes ⇒ Object
Returns the value of attribute indexes.
6 7 8 |
# File 'lib/sixarm_ruby_active_record_migration_mock/active_record_migration_table_mock.rb', line 6 def indexes @indexes end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/sixarm_ruby_active_record_migration_mock/active_record_migration_table_mock.rb', line 4 def name @name end |
Instance Method Details
#column(column_name, column_type, column_options = {}) ⇒ Object
20 21 22 23 24 |
# File 'lib/sixarm_ruby_active_record_migration_mock/active_record_migration_table_mock.rb', line 20 def column(column_name, column_type, = {}) col = ActiveRecordMigrationColumnMock.new(column_name, column_type, ) @columns[column_name] = col col end |
#has_column?(column_name) ⇒ Boolean
26 27 28 |
# File 'lib/sixarm_ruby_active_record_migration_mock/active_record_migration_table_mock.rb', line 26 def has_column?(column_name) @columns[column_name] != nil end |
#has_index?(column_name) ⇒ Boolean
36 37 38 |
# File 'lib/sixarm_ruby_active_record_migration_mock/active_record_migration_table_mock.rb', line 36 def has_index?(column_name) @indexes[column_name] != nil end |
#index(column_name) ⇒ Object
30 31 32 33 34 |
# File 'lib/sixarm_ruby_active_record_migration_mock/active_record_migration_table_mock.rb', line 30 def index(column_name) ind = ActiveRecordMigrationIndexMock.new(name, column_name) @indexes[column_name] = ind ind end |
#to_s ⇒ Object
14 15 16 17 18 |
# File 'lib/sixarm_ruby_active_record_migration_mock/active_record_migration_table_mock.rb', line 14 def to_s "table name:#{name}\n" + @columns.values.map{|x| x.to_s + "\n"}.join + @indexes.values.map{|x| x.to_s + "\n"}.join end |