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, #column_default_changed?, #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.



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

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

Instance Method Details

#column_defaultsObject



99
100
101
102
103
104
105
# File 'lib/dsl/data_types/primitives.rb', line 99

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



107
108
109
# File 'lib/dsl/data_types/primitives.rb', line 107

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