Module: ActiveRecord::Comments::BaseExt::ClassMethods
- Defined in:
- lib/activerecord-comments/base_ext.rb
Instance Method Summary collapse
-
#column_comment(column, table = self.table_name) ⇒ Object
Get the database comment (if any) defined for a column.
-
#columns_with_table_name(*args) ⇒ Object
Extends ActiveRecord::Base#columns, setting @table_name as an instance variable on each of the column instances that are returned.
-
#comment(table = self.table_name) ⇒ Object
Get the database comment (if any) defined for a table.
Instance Method Details
#column_comment(column, table = self.table_name) ⇒ Object
Get the database comment (if any) defined for a column
TODO move into adapter!
Parameters
- column<~to_s>
-
The name of the column to get the comment for
- table<~to_s>
-
The name of the table to get the column comment for, default is the #table_name of the ActiveRecord::Base class this is being called on, eg. User.column_comment ‘username’
Returns
- String
-
The comment for the given column (or nil if no comment)
:api: public
48 49 50 |
# File 'lib/activerecord-comments/base_ext.rb', line 48 def column_comment column, table = self.table_name connection.column_comment column, table end |
#columns_with_table_name(*args) ⇒ Object
Extends ActiveRecord::Base#columns, setting @table_name as an instance variable on each of the column instances that are returned
Returns
- Array
-
Returns an Array of column objects, each with @table_name set
:api: private
60 61 62 63 64 65 66 67 |
# File 'lib/activerecord-comments/base_ext.rb', line 60 def columns_with_table_name *args columns = columns_without_table_name *args table = self.table_name # make table_name available as variable in instanve_eval closure columns.each do |column| column.instance_eval { @table_name = table } end columns end |
#comment(table = self.table_name) ⇒ Object
Get the database comment (if any) defined for a table
Parameters
- table<~to_s>
-
The name of the table to get the comment for, default is the #table_name of the ActiveRecord::Base class this is being called on, eg.
User.comment
Returns
- String
-
The comment for the given table (or nil if no comment)
:api: public
27 28 29 |
# File 'lib/activerecord-comments/base_ext.rb', line 27 def comment table = self.table_name connection.comment table end |