Class: AnnotateRb::ModelAnnotator::Annotation::AnnotationBuilder::Annotation
- Inherits:
-
Components::Base
- Object
- Components::Base
- AnnotateRb::ModelAnnotator::Annotation::AnnotationBuilder::Annotation
- Defined in:
- lib/annotate_rb/model_annotator/annotation/annotation_builder.rb
Instance Attribute Summary collapse
-
#database_name ⇒ Object
readonly
Returns the value of attribute database_name.
-
#max_size ⇒ Object
readonly
Returns the value of attribute max_size.
-
#table_comment ⇒ Object
readonly
Returns the value of attribute table_comment.
-
#table_name ⇒ Object
readonly
Returns the value of attribute table_name.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #body ⇒ Object
- #build ⇒ Object
-
#initialize(options, **input) ⇒ Annotation
constructor
A new instance of Annotation.
Methods inherited from Components::Base
#to_default, #to_markdown, #to_rdoc, #to_yard
Constructor Details
#initialize(options, **input) ⇒ Annotation
Returns a new instance of Annotation.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/annotate_rb/model_annotator/annotation/annotation_builder.rb', line 10 def initialize(, **input) @options = @version = input[:version] @table_name = input[:table_name] @table_comment = input[:table_comment] @max_size = input[:max_size] @model = input[:model] @database_name = input[:database_name] end |
Instance Attribute Details
#database_name ⇒ Object (readonly)
Returns the value of attribute database_name.
8 9 10 |
# File 'lib/annotate_rb/model_annotator/annotation/annotation_builder.rb', line 8 def database_name @database_name end |
#max_size ⇒ Object (readonly)
Returns the value of attribute max_size.
8 9 10 |
# File 'lib/annotate_rb/model_annotator/annotation/annotation_builder.rb', line 8 def max_size @max_size end |
#table_comment ⇒ Object (readonly)
Returns the value of attribute table_comment.
8 9 10 |
# File 'lib/annotate_rb/model_annotator/annotation/annotation_builder.rb', line 8 def table_comment @table_comment end |
#table_name ⇒ Object (readonly)
Returns the value of attribute table_name.
8 9 10 |
# File 'lib/annotate_rb/model_annotator/annotation/annotation_builder.rb', line 8 def table_name @table_name end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
8 9 10 |
# File 'lib/annotate_rb/model_annotator/annotation/annotation_builder.rb', line 8 def version @version end |
Instance Method Details
#body ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/annotate_rb/model_annotator/annotation/annotation_builder.rb', line 21 def body [ MainHeader.new(version, @options[:include_version]), SchemaHeader.new(table_name, table_comment, database_name, @options), MarkdownHeader.new(max_size), *columns, IndexAnnotation::AnnotationBuilder.new(@model, @options).build, ForeignKeyAnnotation::AnnotationBuilder.new(@model, @options).build, CheckConstraintAnnotation::AnnotationBuilder.new(@model, @options).build, EnumAnnotation::AnnotationBuilder.new(@model, @options).build, SchemaFooter.new ] end |
#build ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/annotate_rb/model_annotator/annotation/annotation_builder.rb', line 35 def build components = body.flatten if @options[:format_rdoc] components.map(&:to_rdoc).compact.join("\n") elsif @options[:format_yard] components.map(&:to_yard).compact.join("\n") elsif @options[:format_markdown] components.map(&:to_markdown).compact.join("\n") else components.map(&:to_default).compact.join("\n") end end |