Module: MigrationComments::ActiveRecord::ConnectionAdapters::TableDefinition

Defined in:
lib/migration_comments/active_record/connection_adapters/table_definition.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#table_commentObject

Returns the value of attribute table_comment.



4
5
6
# File 'lib/migration_comments/active_record/connection_adapters/table_definition.rb', line 4

def table_comment
  @table_comment
end

Class Method Details

.included(base) ⇒ Object



5
6
7
8
9
10
# File 'lib/migration_comments/active_record/connection_adapters/table_definition.rb', line 5

def self.included(base)
  base.class_eval do
    alias_method_chain :column, :migration_comments
    attr_accessor :base
  end
end

Instance Method Details

#collect_comments(table_name) ⇒ Object



26
27
28
29
30
31
# File 'lib/migration_comments/active_record/connection_adapters/table_definition.rb', line 26

def collect_comments(table_name)
  comments = []
  comments << @table_comment << columns.map(&:comment)
  comments.flatten!.compact!
  comments.each{|comment| comment.table = table_name; comment.adapter = base}
end

#column_with_migration_comments(name, type, options = {}) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/migration_comments/active_record/connection_adapters/table_definition.rb', line 17

def column_with_migration_comments(name, type, options = {})
  column_without_migration_comments(name, type, options)
  if options.has_key?(:comment)
    col = self[name]
    col.comment = CommentDefinition.new(base, nil, name, options[:comment])
  end
  self
end

#comment(text) ⇒ Object



12
13
14
15
# File 'lib/migration_comments/active_record/connection_adapters/table_definition.rb', line 12

def comment(text)
  @table_comment = CommentDefinition.new(base, nil, nil, text)
  self
end