Class: AnnotateRb::ModelAnnotator::Annotation::AnnotationBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/annotate_rb/model_annotator/annotation/annotation_builder.rb

Defined Under Namespace

Classes: Annotation

Instance Method Summary collapse

Constructor Details

#initialize(klass, options) ⇒ AnnotationBuilder

Returns a new instance of AnnotationBuilder.



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

def initialize(klass, options)
  @model = ModelWrapper.new(klass, options)
  @options = options
end

Instance Method Details

#buildObject



61
62
63
64
65
66
67
68
69
70
# File 'lib/annotate_rb/model_annotator/annotation/annotation_builder.rb', line 61

def build
  version = @model.migration_version
  table_name = @model.table_name
  table_comment = @model.connection.try(:table_comment, @model.table_name)
  max_size = @model.max_schema_info_width

  _annotation = Annotation.new(@options,
    version: version, table_name: table_name, table_comment: table_comment,
    max_size: max_size, model: @model).build
end