Sha256: 36ce3ee6d11550be44438f060dd0ecd2c0be086701c19f0876c13f82fc5852c9

Contents?: true

Size: 923 Bytes

Versions: 3

Compression:

Stored size: 923 Bytes

Contents

# QBS https://github.com/coocood/qbs
require "ar2gostruct/builder/orm/base"
module Ar2gostruct
  module Builder
    module ORM
      class QBS < Base

        def get_option(col)
          orm_option = []
          # primary key
          if col.name == @klass.primary_key
            orm_option << "pk"
          end
          # not null Constraint
          unless col.null
            orm_option << "notnull"
          end
          # default value
          if col.default
            orm_option << "default:'#{col.default}'"
          end
          # set timestamp
          if col.name == "created_at"
            orm_option << "created"
          elsif col.name == "updated_at"
            orm_option << "updated"
          end
          if orm_option.present?
            return "qbs:\"#{orm_option.join(TAG_SEPARATOR)}\""
          else
            return nil
          end
        end

      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ar2gostruct-0.2.2 lib/ar2gostruct/builder/orm/qbs.rb
ar2gostruct-0.2.1 lib/ar2gostruct/builder/orm/qbs.rb
ar2gostruct-0.2.0 lib/ar2gostruct/builder/orm/qbs.rb