Class: AnnotateRb::ModelAnnotator::IndexAnnotation::AnnotationBuilder
- Inherits:
-
Object
- Object
- AnnotateRb::ModelAnnotator::IndexAnnotation::AnnotationBuilder
- Defined in:
- lib/annotate_rb/model_annotator/index_annotation/annotation_builder.rb
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.
7 8 9 10 |
# File 'lib/annotate_rb/model_annotator/index_annotation/annotation_builder.rb', line 7 def initialize(model, ) @model = model @options = end |
Instance Method Details
#build ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/annotate_rb/model_annotator/index_annotation/annotation_builder.rb', line 12 def build return Components::NilComponent.new if !@options[:show_indexes] indexes = @model.retrieve_indexes_from_table return Components::NilComponent.new if indexes.empty? max_size = indexes.map { |index| index.name.size }.max + 1 indexes = indexes.sort_by(&:name).map do |index| IndexComponent.new(index, max_size) end _annotation = Annotation.new(indexes) end |