Sha256: 34ca72c16ec0aec62560e88cf976cac4c3446d4fed5c1c936802468734ac17d3

Contents?: true

Size: 473 Bytes

Versions: 2

Compression:

Stored size: 473 Bytes

Contents

module DataType
  class String < Base
    def initialize(options)
      super(options)
      @value ||= ''
    end
  
    def column
      if @value.match(/[\d,]+\.\d{2}$/)
        return Currency.new(@options).column
      else
        return @value.match(/[\r\n\t]/)? { :type => :text }.merge(@options) : super
      end
    end
    
    def mock
      @value || ((self.column[:type] == :text)? self.class.long_text_mock : self.class.default_mock )
    end
  end
end
  

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
migrant-1.1.1 lib/datatype/string.rb
migrant-1.1.0 lib/datatype/string.rb