Class: AnnotateRb::ModelAnnotator::Annotation::SchemaHeader

Inherits:
Components::Base show all
Defined in:
lib/annotate_rb/model_annotator/annotation/schema_header.rb

Defined Under Namespace

Classes: DatabaseName, TableName

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Components::Base

#to_rdoc, #to_yard

Constructor Details

#initialize(table_name, table_comment, database_name, options) ⇒ SchemaHeader

Returns a new instance of SchemaHeader.



41
42
43
44
45
46
# File 'lib/annotate_rb/model_annotator/annotation/schema_header.rb', line 41

def initialize(table_name, table_comment, database_name, options)
  @table_name = table_name
  @table_comment = table_comment
  @database_name = database_name
  @options = options
end

Instance Attribute Details

#database_nameObject (readonly)

Returns the value of attribute database_name.



39
40
41
# File 'lib/annotate_rb/model_annotator/annotation/schema_header.rb', line 39

def database_name
  @database_name
end

#table_commentObject (readonly)

Returns the value of attribute table_comment.



39
40
41
# File 'lib/annotate_rb/model_annotator/annotation/schema_header.rb', line 39

def table_comment
  @table_comment
end

#table_nameObject (readonly)

Returns the value of attribute table_name.



39
40
41
# File 'lib/annotate_rb/model_annotator/annotation/schema_header.rb', line 39

def table_name
  @table_name
end

Instance Method Details

#bodyObject



48
49
50
51
52
53
54
55
# File 'lib/annotate_rb/model_annotator/annotation/schema_header.rb', line 48

def body
  [
    Components::BlankCommentLine.new,
    TableName.new(name),
    (DatabaseName.new(database_name) if database_name),
    Components::BlankCommentLine.new
  ].compact
end

#to_defaultObject



57
58
59
# File 'lib/annotate_rb/model_annotator/annotation/schema_header.rb', line 57

def to_default
  body.map(&:to_default).join("\n")
end

#to_markdownObject



61
62
63
# File 'lib/annotate_rb/model_annotator/annotation/schema_header.rb', line 61

def to_markdown
  body.map(&:to_markdown).join("\n")
end