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) ⇒ ColumnWrapper

Returns a new instance of ColumnWrapper.



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

def initialize(column)
  @column = column
end

Instance Method Details

#array?Boolean

Returns:

  • (Boolean)


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

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

#column_type_stringObject



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

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

#defaultObject



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

def default
  # Note: Used to be klass.column_defaults[name], where name is the column name.
  # Looks to be identical, but keeping note here in case there are differences.
  _column_default = @column.default
end

#default_stringObject



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

def default_string
  quote(@column.default)
end

#geometric_typeObject



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

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)


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

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

#geometry_typeObject



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

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)


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

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

#limitObject



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

def limit
  @column.limit
end

#nameObject



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

def name
  @column.name
end

#nullObject



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

def null
  @column.null
end

#precisionObject



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

def precision
  @column.precision
end

#scaleObject



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

def scale
  @column.scale
end

#sridObject



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

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

#typeObject



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

def type
  @column.type
end

#unsigned?Boolean

Returns:

  • (Boolean)


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

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