Module: ActiveRecord::Comments::MysqlAdapter::ClassMethods

Defined in:
lib/activerecord-comments/mysql_adapter.rb

Instance Method Summary collapse

Instance Method Details

#mysql_column_comment(column, table) ⇒ Object

MySQL implementation of ActiveRecord::Comments::BaseExt#column_comment



20
21
22
23
24
25
26
27
# File 'lib/activerecord-comments/mysql_adapter.rb', line 20

def mysql_column_comment column, table
  column_creation_sql = create_column_sql(column, table)
  if column_creation_sql =~ /COMMENT '/
    /COMMENT '(.*)'/.match(column_creation_sql).captures.first
  else
    nil
  end
end

#mysql_comment(table) ⇒ Object

MySQL implementation of ActiveRecord::Comments::BaseExt#comment



10
11
12
13
14
15
16
17
# File 'lib/activerecord-comments/mysql_adapter.rb', line 10

def mysql_comment table
  table_options = create_table_sql(table).split("\n").last
  if table_options =~ /COMMENT='/
    /COMMENT='(.*)'/.match(table_options).captures.first
  else
    nil
  end
end