Class: RailsDb::Table
- Inherits:
-
Object
- Object
- RailsDb::Table
- Includes:
- Connection
- Defined in:
- lib/rails_db/table.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #delete(id) ⇒ Object
- #indexes ⇒ Object
-
#initialize(table_name) ⇒ Table
constructor
A new instance of Table.
- #primary_key ⇒ Object
- #to_csv ⇒ Object
- #truncate ⇒ Object
Methods included from Connection
#column_names, #column_properties, #columns, #connection, #to_param
Constructor Details
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
8 9 10 |
# File 'lib/rails_db/table.rb', line 8 def data @data end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/rails_db/table.rb', line 8 def name @name end |
Instance Method Details
#delete(id) ⇒ Object
44 45 46 |
# File 'lib/rails_db/table.rb', line 44 def delete(id) RailsDb::Database.adapter.delete(name, primary_key, id) end |
#indexes ⇒ Object
32 33 34 |
# File 'lib/rails_db/table.rb', line 32 def indexes connection.indexes(name) end |
#primary_key ⇒ Object
40 41 42 |
# File 'lib/rails_db/table.rb', line 40 def primary_key connection.primary_key(name) end |
#to_csv ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/rails_db/table.rb', line 23 def to_csv CSV.generate do |csv| csv << column_names data.data.rows.each do |row| csv << row end end end |