Class: AnnotateRb::ModelAnnotator::ColumnAnnotation::AnnotationBuilder
- Inherits:
-
Object
- Object
- AnnotateRb::ModelAnnotator::ColumnAnnotation::AnnotationBuilder
- Defined in:
- lib/annotate_rb/model_annotator/column_annotation/annotation_builder.rb
Constant Summary collapse
- BARE_TYPE_ALLOWANCE =
16- MD_TYPE_ALLOWANCE =
18
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(column, model, max_size, options) ⇒ AnnotationBuilder
constructor
A new instance of AnnotationBuilder.
Constructor Details
#initialize(column, model, max_size, options) ⇒ AnnotationBuilder
Returns a new instance of AnnotationBuilder.
10 11 12 13 14 15 |
# File 'lib/annotate_rb/model_annotator/column_annotation/annotation_builder.rb', line 10 def initialize(column, model, max_size, ) @column = column @model = model @max_size = max_size = end |
Instance Method Details
#build ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/annotate_rb/model_annotator/column_annotation/annotation_builder.rb', line 17 def build result = "" is_primary_key = is_column_primary_key?(@model, @column.name) table_indices = @model.retrieve_indexes_from_table column_indices = table_indices.select { |ind| ind.columns.include?(@column.name) } column_attributes = AttributesBuilder.new(@column, , is_primary_key, column_indices).build formatted_column_type = TypeBuilder.new(@column, ).build col_name = if @model.with_comments? && @column.comment "#{@column.name}(#{@column.comment.gsub(/\n/, '\\n')})" else @column.name end result += if [:format_rdoc] format_rdoc(col_name, @max_size, formatted_column_type, column_attributes) elsif [:format_yard] format_yard(col_name, @max_size, formatted_column_type, column_attributes) elsif [:format_markdown] format_markdown(col_name, @max_size, formatted_column_type, column_attributes) else format_default(col_name, @max_size, formatted_column_type, column_attributes) end result end |