Class: DbDiff::Table
- Inherits:
-
Object
- Object
- DbDiff::Table
- Defined in:
- lib/dbdiff/table.rb
Instance Attribute Summary collapse
-
#charset ⇒ Object
Returns the value of attribute charset.
-
#collation ⇒ Object
Returns the value of attribute collation.
-
#columns ⇒ Object
Returns the value of attribute columns.
-
#engine ⇒ Object
Returns the value of attribute engine.
-
#foreign_keys ⇒ Object
Returns the value of attribute foreign_keys.
-
#keys ⇒ Object
Returns the value of attribute keys.
-
#name ⇒ Object
(also: #table_name)
readonly
Returns the value of attribute name.
-
#rows ⇒ Object
Returns the value of attribute rows.
-
#triggers ⇒ Object
Returns the value of attribute triggers.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #add_delta ⇒ Object
- #deep_clone ⇒ Object
- #drop_delta ⇒ Object
-
#initialize(info = {}) ⇒ Table
constructor
A new instance of Table.
- #modify_delta(new_element) ⇒ Object
- #primary_key ⇒ Object
Constructor Details
#initialize(info = {}) ⇒ Table
Returns a new instance of Table.
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/dbdiff/table.rb', line 6 def initialize(info = {}) @rows = [] @foreign_keys = [] @keys = [] @columns = [] @triggers = [] @engine = info['ENGINE'] @collation = info['TABLE_COLLATION'] @name = info['TABLE_NAME'] end |
Instance Attribute Details
#charset ⇒ Object
Returns the value of attribute charset.
4 5 6 |
# File 'lib/dbdiff/table.rb', line 4 def charset @charset end |
#collation ⇒ Object
Returns the value of attribute collation.
4 5 6 |
# File 'lib/dbdiff/table.rb', line 4 def collation @collation end |
#columns ⇒ Object
Returns the value of attribute columns.
4 5 6 |
# File 'lib/dbdiff/table.rb', line 4 def columns @columns end |
#engine ⇒ Object
Returns the value of attribute engine.
4 5 6 |
# File 'lib/dbdiff/table.rb', line 4 def engine @engine end |
#foreign_keys ⇒ Object
Returns the value of attribute foreign_keys.
4 5 6 |
# File 'lib/dbdiff/table.rb', line 4 def foreign_keys @foreign_keys end |
#keys ⇒ Object
Returns the value of attribute keys.
4 5 6 |
# File 'lib/dbdiff/table.rb', line 4 def keys @keys end |
#name ⇒ Object (readonly) Also known as: table_name
Returns the value of attribute name.
3 4 5 |
# File 'lib/dbdiff/table.rb', line 3 def name @name end |
#rows ⇒ Object
Returns the value of attribute rows.
4 5 6 |
# File 'lib/dbdiff/table.rb', line 4 def rows @rows end |
#triggers ⇒ Object
Returns the value of attribute triggers.
4 5 6 |
# File 'lib/dbdiff/table.rb', line 4 def triggers @triggers end |
Instance Method Details
#==(other) ⇒ Object
26 27 28 29 30 |
# File 'lib/dbdiff/table.rb', line 26 def ==(other) self.engine == other.engine && self.collation == other.collation && self.name == other.name end |
#add_delta ⇒ Object
37 38 39 |
# File 'lib/dbdiff/table.rb', line 37 def add_delta Delta::AddTable.new(self) end |
#deep_clone ⇒ Object
32 33 34 35 |
# File 'lib/dbdiff/table.rb', line 32 def deep_clone t = Marshal::load(Marshal.dump(self)) # must clear rows out since they won't necessary be in the copy end |
#drop_delta ⇒ Object
45 46 47 |
# File 'lib/dbdiff/table.rb', line 45 def drop_delta Delta::DropTable.new(self) end |
#modify_delta(new_element) ⇒ Object
41 42 43 |
# File 'lib/dbdiff/table.rb', line 41 def modify_delta(new_element) Delta::ModifyTable.new(new_element) end |
#primary_key ⇒ Object
21 22 23 24 |
# File 'lib/dbdiff/table.rb', line 21 def primary_key pk = keys.find{|k| k.primary} return (pk ? pk.columns : nil) end |