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.



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

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

Instance Method Details

#buildObject



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

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
  database_name = @model.database_name if multi_db_environment?

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