Class: WhoAmI::TableInfo
- Inherits:
-
Object
- Object
- WhoAmI::TableInfo
- Defined in:
- lib/who_am_i/table_info.rb
Instance Attribute Summary collapse
-
#table_name ⇒ Object
readonly
Returns the value of attribute table_name.
Instance Method Summary collapse
- #columns ⇒ Object
- #indices ⇒ Object
-
#initialize(table_name) ⇒ TableInfo
constructor
A new instance of TableInfo.
Constructor Details
#initialize(table_name) ⇒ TableInfo
Returns a new instance of TableInfo.
3 4 5 |
# File 'lib/who_am_i/table_info.rb', line 3 def initialize(table_name) @table_name = table_name end |
Instance Attribute Details
#table_name ⇒ Object (readonly)
Returns the value of attribute table_name.
7 8 9 |
# File 'lib/who_am_i/table_info.rb', line 7 def table_name @table_name end |
Instance Method Details
#columns ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/who_am_i/table_info.rb', line 9 def columns @columns ||= begin columns_hash = ActiveRecord::Base.connection.schema_cache.columns_hash(@table_name) columns_hash.values.map do |column| TableColumnInfo.new(table_name: @table_name, column: column) end end end |
#indices ⇒ Object
21 22 23 |
# File 'lib/who_am_i/table_info.rb', line 21 def indices @indices ||= ActiveRecord::Base.connection.indexes(@table_name) end |