Class: AnnotateRb::ModelAnnotator::IndexAnnotation::AnnotationBuilder
- Inherits:
-
Object
- Object
- AnnotateRb::ModelAnnotator::IndexAnnotation::AnnotationBuilder
- Defined in:
- lib/annotate_rb/model_annotator/index_annotation/annotation_builder.rb
Constant Summary collapse
- INDEX_CLAUSES =
{ unique: { default: "UNIQUE", markdown: "_unique_" }, where: { default: "WHERE", markdown: "_where_" }, using: { default: "USING", markdown: "_using_" } }.freeze
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(model, options) ⇒ AnnotationBuilder
constructor
A new instance of AnnotationBuilder.
Constructor Details
#initialize(model, options) ⇒ AnnotationBuilder
Returns a new instance of AnnotationBuilder.
22 23 24 25 |
# File 'lib/annotate_rb/model_annotator/index_annotation/annotation_builder.rb', line 22 def initialize(model, ) @model = model = end |
Instance Method Details
#build ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/annotate_rb/model_annotator/index_annotation/annotation_builder.rb', line 27 def build index_info = if [:format_markdown] "#\n# ### Indexes\n#\n" else "#\n# Indexes\n#\n" end indexes = @model.retrieve_indexes_from_table return "" if indexes.empty? max_size = indexes.collect { |index| index.name.size }.max + 1 indexes.sort_by(&:name).each do |index| index_info += if [:format_markdown] final_index_string_in_markdown(index) else final_index_string(index, max_size) end end index_info end |