Module: PgSaurus::ConnectionAdapters::Table::CommentMethods

Included in:
PgSaurus::ConnectionAdapters::Table
Defined in:
lib/pg_saurus/connection_adapters/table/comment_methods.rb

Overview

Provides methods to extend ActiveRecord::ConnectionAdapters::Table to support comments feature.

Instance Method Summary collapse

Instance Method Details

#remove_column_comment(column_name) ⇒ Object

Remove any comment for a given column.

Example
Remove comment from the npa column
t.remove_column_comment :npa


46
47
48
# File 'lib/pg_saurus/connection_adapters/table/comment_methods.rb', line 46

def remove_column_comment(column_name)
  @base.remove_column_comment(@name, column_name)
end

#remove_column_comments(*column_names) ⇒ Object

Remove any comments from the given columns.

Example
Remove comment from the npa and nxx columns
t.remove_column_comment :npa, :nxx


55
56
57
# File 'lib/pg_saurus/connection_adapters/table/comment_methods.rb', line 55

def remove_column_comments(*column_names)
  @base.remove_column_comments(@name, *column_names)
end

#remove_table_commentObject

Remove any comment from the table.

Example
Remove table comment
t.remove_table_comment


18
19
20
# File 'lib/pg_saurus/connection_adapters/table/comment_methods.rb', line 18

def remove_table_comment
  @base.remove_table_comment(@name)
end

#set_column_comment(column_name, comment) ⇒ Object

Set the comment for a given column.

Example
Set comment on the npa column
t.set_column_comment :npa, 'Numbering Plan Area Code - Allowed ranges: [2-9] for first digit, [0-9] for second and third digit.'


27
28
29
# File 'lib/pg_saurus/connection_adapters/table/comment_methods.rb', line 27

def set_column_comment(column_name, comment)
  @base.set_column_comment(@name, column_name, comment)
end

#set_column_comments(comments) ⇒ Object

Set comments on multiple columns. ‘comments’ is a hash of column_name => comment pairs.

Example
Setting comments on the columns of the phone_numbers table
t.set_column_comments :npa => 'Numbering Plan Area Code - Allowed ranges: [2-9] for first digit, [0-9] for second and third digit.',
                      :nxx => 'Central Office Number'


37
38
39
# File 'lib/pg_saurus/connection_adapters/table/comment_methods.rb', line 37

def set_column_comments(comments)
  @base.set_column_comments(@name, comments)
end

#set_table_comment(comment) ⇒ Object

Set the comment on the table.

Example
Set comment on table
t.set_table_comment 'This table stores phone numbers that conform to the North American Numbering Plan.'


9
10
11
# File 'lib/pg_saurus/connection_adapters/table/comment_methods.rb', line 9

def set_table_comment(comment)
  @base.set_table_comment(@name, comment)
end