Class: AnnotateRb::ModelAnnotator::ColumnAnnotation::DefaultValueBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/annotate_rb/model_annotator/column_annotation/default_value_builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(value, options) ⇒ DefaultValueBuilder

Returns a new instance of DefaultValueBuilder.



7
8
9
10
# File 'lib/annotate_rb/model_annotator/column_annotation/default_value_builder.rb', line 7

def initialize(value, options)
  @value = value
  @options = options
end

Instance Method Details

#buildString

Returns the value to get written to file by file.puts. Strings get written to file so escaped quoted strings get written as quoted. For example, if ‘value: “"some_string"”` then “some_string” gets written. Same with arrays, if `value: “["a", "b", "c"]”` then `[“a”, “b”, “c”]` gets written.

Examples:

“"some_string"”

“NULL”

“1.2”

Returns:

  • (String)


20
21
22
23
24
25
26
# File 'lib/annotate_rb/model_annotator/column_annotation/default_value_builder.rb', line 20

def build
  if @value.is_a?(Array)
    quote_array(@value)
  else
    quote(@value)
  end
end