Module: DbAgile::Contract::Schema::TableDriven
- Included in:
- Utils::Full
- Defined in:
- lib/dbagile/contract/schema/table_driven.rb
Overview
Table-driven adapter read-only methods about schemas.
Instance Method Summary collapse
-
#column_names(table_name, sort = false) ⇒ Array<Symbol>
Returns the list of column names for a given table.
-
#has_column?(table_name, column_name) ⇒ Boolean
Returns true if a column exists, false otherwise.
-
#has_table?(table_name) ⇒ Boolean
Returns true if a given table exists in the database, false otherwise.
-
#heading(table_name) ⇒ Hash<Symbol => Class>
Returns the heading of a given table.
-
#is_key?(table_name, columns) ⇒ Boolean
Checks if an array of column names for a key for a given table.
-
#keys(table_name) ⇒ Array<Array<Symbol>>
Returns available keys for a given table as an array of column names.
Instance Method Details
#column_names(table_name, sort = false) ⇒ Array<Symbol>
Returns the list of column names for a given table.
55 56 57 |
# File 'lib/dbagile/contract/schema/table_driven.rb', line 55 def column_names(table_name, sort = false) Kernel.raise NotImplementedError end |
#has_column?(table_name, column_name) ⇒ Boolean
Returns true if a column exists, false otherwise.
A default implementation is provided that relies on column_names.
30 31 32 |
# File 'lib/dbagile/contract/schema/table_driven.rb', line 30 def has_column?(table_name, column_name) column_names(table_name).include?(column_name) end |
#has_table?(table_name) ⇒ Boolean
Returns true if a given table exists in the database, false otherwise.
15 16 17 |
# File 'lib/dbagile/contract/schema/table_driven.rb', line 15 def has_table?(table_name) Kernel.raise NotImplementedError end |
#heading(table_name) ⇒ Hash<Symbol => Class>
Returns the heading of a given table.
42 43 44 |
# File 'lib/dbagile/contract/schema/table_driven.rb', line 42 def heading(table_name) Kernel.raise NotImplementedError end |
#is_key?(table_name, columns) ⇒ Boolean
Checks if an array of column names for a key for a given table.
69 70 71 |
# File 'lib/dbagile/contract/schema/table_driven.rb', line 69 def is_key?(table_name, columns) keys(table_name).include?(columns) end |
#keys(table_name) ⇒ Array<Array<Symbol>>
Returns available keys for a given table as an array of column names.
82 83 84 |
# File 'lib/dbagile/contract/schema/table_driven.rb', line 82 def keys(table_name) Kernel.raise NotImplementedError end |