Sha256: 7c92a136cea50c48aa0636395f0d290c75047587a5f2bcb6924030e87124193e

Contents?: true

Size: 590 Bytes

Versions: 9

Compression:

Stored size: 590 Bytes

Contents

module Rasti
  module DB
    module TypeConverters
      module SQLiteTypes
        class Array

          class << self

            def column_type_regex
              /^([a-z]+)\[\]$/
            end

            def to_db(values)
              JSON.dump(values)
            end

            def respond_for?(object)
              parsed = JSON.parse object
              object == to_db(parsed)
            rescue
              false
            end

            def from_db(object)
              JSON.parse object
            end

          end

        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rasti-db-4.2.0 lib/rasti/db/type_converters/sqlite_types/array.rb
rasti-db-4.1.1 lib/rasti/db/type_converters/sqlite_types/array.rb
rasti-db-4.1.0 lib/rasti/db/type_converters/sqlite_types/array.rb
rasti-db-4.0.0 lib/rasti/db/type_converters/sqlite_types/array.rb
rasti-db-3.0.0 lib/rasti/db/type_converters/sqlite_types/array.rb
rasti-db-2.3.3 lib/rasti/db/type_converters/sqlite_types/array.rb
rasti-db-2.3.2 lib/rasti/db/type_converters/sqlite_types/array.rb
rasti-db-2.3.1 lib/rasti/db/type_converters/sqlite_types/array.rb
rasti-db-2.3.0 lib/rasti/db/type_converters/sqlite_types/array.rb