Class: AnnotateRb::ModelAnnotator::ColumnAnnotation::AnnotationBuilder
- Inherits:
-
Object
- Object
- AnnotateRb::ModelAnnotator::ColumnAnnotation::AnnotationBuilder
- Defined in:
- lib/annotate_rb/model_annotator/column_annotation/annotation_builder.rb
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.
7 8 9 10 11 12 |
# File 'lib/annotate_rb/model_annotator/column_annotation/annotation_builder.rb', line 7 def initialize(column, model, max_size, ) @column = column @model = model @max_size = max_size @options = end |
Instance Method Details
#build ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/annotate_rb/model_annotator/column_annotation/annotation_builder.rb', line 14 def build 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_defaults = @model.column_defaults column_attributes = AttributesBuilder.new(@column, @options, is_primary_key, column_indices, column_defaults).build formatted_column_type = TypeBuilder.new(@column, @options, column_defaults).build display_column_comments = @options[:with_comment] && @options[:with_column_comments] col_name = if display_column_comments && @model.with_comments? && @column.comment "#{@column.name}(#{@column.comment.gsub(/\n/, '\\n')})" else @column.name end _component = ColumnComponent.new(col_name, @max_size, formatted_column_type, column_attributes) end |