Class: MigrationComments::ActiveRecord::ConnectionAdapters::CommentDefinition

Inherits:
Struct
  • Object
show all
Defined in:
lib/migration_comments/active_record/connection_adapters/comment_definition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#adapterObject

Returns the value of attribute adapter

Returns:

  • (Object)

    the current value of adapter



2
3
4
# File 'lib/migration_comments/active_record/connection_adapters/comment_definition.rb', line 2

def adapter
  @adapter
end

#column_nameObject

Returns the value of attribute column_name

Returns:

  • (Object)

    the current value of column_name



2
3
4
# File 'lib/migration_comments/active_record/connection_adapters/comment_definition.rb', line 2

def column_name
  @column_name
end

#comment_textObject

Returns the value of attribute comment_text

Returns:

  • (Object)

    the current value of comment_text



2
3
4
# File 'lib/migration_comments/active_record/connection_adapters/comment_definition.rb', line 2

def comment_text
  @comment_text
end

#tableObject

Returns the value of attribute table

Returns:

  • (Object)

    the current value of table



2
3
4
# File 'lib/migration_comments/active_record/connection_adapters/comment_definition.rb', line 2

def table
  @table
end

Instance Method Details

#table_comment?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/migration_comments/active_record/connection_adapters/comment_definition.rb', line 14

def table_comment?
  column_name.blank?
end

#table_nameObject



18
19
20
# File 'lib/migration_comments/active_record/connection_adapters/comment_definition.rb', line 18

def table_name
  table.respond_to?(:name) ? table.name : table
end

#to_dumpObject



3
4
5
6
7
# File 'lib/migration_comments/active_record/connection_adapters/comment_definition.rb', line 3

def to_dump
  table_comment? ?
      "set_table_comment :#{table_name}, %{#{comment_text}}" :
      "set_column_comment :#{table_name}, :#{column_name}, %{#{comment_text}}"
end

#to_sqlObject Also known as: to_s



9
10
11
# File 'lib/migration_comments/active_record/connection_adapters/comment_definition.rb', line 9

def to_sql
  adapter.comment_sql(self)
end