Class: AnnotateRb::ModelAnnotator::ColumnAnnotation::ColumnWrapper

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

Instance Method Summary collapse

Constructor Details

#initialize(column, column_defaults, options) ⇒ ColumnWrapper

Returns a new instance of ColumnWrapper.



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

def initialize(column, column_defaults, options)
  @column = column
  @column_defaults = column_defaults
  @options = options
end

Instance Method Details

#array?Boolean

Returns:

  • (Boolean)


80
81
82
# File 'lib/annotate_rb/model_annotator/column_annotation/column_wrapper.rb', line 80

def array?
  @column.respond_to?(:array) && @column.array
end

#column_type_stringObject



29
30
31
32
33
34
35
# File 'lib/annotate_rb/model_annotator/column_annotation/column_wrapper.rb', line 29

def column_type_string
  if (@column.respond_to?(:bigint?) && @column.bigint?) || /\Abigint\b/ =~ @column.sql_type
    "bigint"
  else
    (@column.type || @column.sql_type).to_s
  end
end

#default_stringObject



21
22
23
# File 'lib/annotate_rb/model_annotator/column_annotation/column_wrapper.rb', line 21

def default_string
  quote(default_value)
end

#default_valueObject



17
18
19
# File 'lib/annotate_rb/model_annotator/column_annotation/column_wrapper.rb', line 17

def default_value
  @column_defaults[@column.name]
end

#geometric_typeObject



70
71
72
73
# File 'lib/annotate_rb/model_annotator/column_annotation/column_wrapper.rb', line 70

def geometric_type
  # TODO: Check if we need to check if it responds before accessing the geometric type
  @column.geometric_type
end

#geometric_type?Boolean

Returns:

  • (Boolean)


66
67
68
# File 'lib/annotate_rb/model_annotator/column_annotation/column_wrapper.rb', line 66

def geometric_type?
  @column.respond_to?(:geometric_type)
end

#geometry_typeObject



61
62
63
64
# File 'lib/annotate_rb/model_annotator/column_annotation/column_wrapper.rb', line 61

def geometry_type
  # TODO: Check if we need to check if it responds before accessing the geometry type
  @column.geometry_type
end

#geometry_type?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/annotate_rb/model_annotator/column_annotation/column_wrapper.rb', line 57

def geometry_type?
  @column.respond_to?(:geometry_type)
end

#limitObject



53
54
55
# File 'lib/annotate_rb/model_annotator/column_annotation/column_wrapper.rb', line 53

def limit
  @column.limit
end

#nameObject



84
85
86
# File 'lib/annotate_rb/model_annotator/column_annotation/column_wrapper.rb', line 84

def name
  @column.name
end

#nullObject



41
42
43
# File 'lib/annotate_rb/model_annotator/column_annotation/column_wrapper.rb', line 41

def null
  @column.null
end

#precisionObject



45
46
47
# File 'lib/annotate_rb/model_annotator/column_annotation/column_wrapper.rb', line 45

def precision
  @column.precision
end

#raw_defaultObject



13
14
15
# File 'lib/annotate_rb/model_annotator/column_annotation/column_wrapper.rb', line 13

def raw_default
  @column.default
end

#scaleObject



49
50
51
# File 'lib/annotate_rb/model_annotator/column_annotation/column_wrapper.rb', line 49

def scale
  @column.scale
end

#sridObject



75
76
77
78
# File 'lib/annotate_rb/model_annotator/column_annotation/column_wrapper.rb', line 75

def srid
  # TODO: Check if we need to check if it responds before accessing the srid
  @column.srid
end

#typeObject



25
26
27
# File 'lib/annotate_rb/model_annotator/column_annotation/column_wrapper.rb', line 25

def type
  @column.type
end

#unsigned?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/annotate_rb/model_annotator/column_annotation/column_wrapper.rb', line 37

def unsigned?
  @column.respond_to?(:unsigned?) && @column.unsigned?
end