Sha256: 242283a80714e1ebdeaaf2acff32e5a72d4e9c8b630bfa6861e12ccb87232ea4

Contents?: true

Size: 479 Bytes

Versions: 14

Compression:

Stored size: 479 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)? %W{Several lines of long text.}.join("\n") : "Some string")
    end
  end
end
  

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
migrant-1.0.2 lib/datatype/string.rb
migrant-1.0.1 lib/datatype/string.rb
migrant-1.0.0 lib/datatype/string.rb
migrant-0.2.4 lib/datatype/string.rb
migrant-0.2.3 lib/datatype/string.rb
migrant-0.2.2 lib/datatype/string.rb
migrant-0.2.1 lib/datatype/string.rb
migrant-0.2.0 lib/datatype/string.rb
migrant-0.1.5 lib/datatype/string.rb
migrant-0.1.4 lib/datatype/string.rb
migrant-0.1.3 lib/datatype/string.rb
migrant-0.1.2 lib/datatype/string.rb
migrant-0.1.1 lib/datatype/string.rb
migrant-0.1.0 lib/datatype/string.rb