Class: DataType::String

Inherits:
Base
  • Object
show all
Defined in:
lib/dsl/data_types/primitives.rb

Overview

Strings

Instance Attribute Summary

Attributes inherited from Base

#aliases

Instance Method Summary collapse

Methods inherited from Base

#==, #column, #dangerous_migration_from?, default_mock, long_text_mock, migrant_data_type?, #serialized?, short_text_mock, #structure_changes_from

Constructor Details

#initialize(options) ⇒ String

Returns a new instance of String.



83
84
85
86
# File 'lib/dsl/data_types/primitives.rb', line 83

def initialize(options)
  super(options)
  @value ||= ''
end

Instance Method Details

#column_defaultsObject



88
89
90
91
92
93
94
# File 'lib/dsl/data_types/primitives.rb', line 88

def column_defaults
  if @value.match(/[\d,]+\.\d{2}$/)
    return Currency.new(@options).column_defaults
  else
    return @value.match(/[\r\n\t]/)? { :type => :text }.merge(@options) : super
  end
end

#mockObject



96
97
98
# File 'lib/dsl/data_types/primitives.rb', line 96

def mock
  @value || ((self.column_defaults[:type] == :text)? self.class.long_text_mock : self.class.default_mock )
end