Sha256: b905a7e4302e719ad63b70824b832a26b3aba374412b88410cebfe57b11f2cf7

Contents?: true

Size: 766 Bytes

Versions: 1

Compression:

Stored size: 766 Bytes

Contents

# GORM https://github.com/jinzhu/gorm
require "ar2gostruct/builder/orm/base"
module Ar2gostruct
  module Builder
    module ORM
      class GORM < Base

        TAG_SEPARATOR = ";"

        def get_option(col)
          orm_option = []
          # not null Constraint
          unless col.null
            orm_option << "not null"
          end
          # set size
          if col.type == :string
            # SQL type
            if col.sql_type
              orm_option << "type:#{col.sql_type}"
            end
            orm_option << "size:#{col.limit}"
          end

          if orm_option.present?
            return "sql:\"#{orm_option.join(TAG_SEPARATOR)}\""
          else
            return nil
          end
        end

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ar2gostruct-0.2.0 lib/ar2gostruct/builder/orm/gorm.rb