Sha256: 75dce43d3a2ee7c211300bb30edd04cfc155f40ab92e3be28be8ec83e7d1edd2
Contents?: true
Size: 992 Bytes
Versions: 1
Compression:
Stored size: 992 Bytes
Contents
module Ahnnotate class Column attr_reader :name attr_reader :type def initialize(name:, type:, nullable:, primary_key:, default:) @name = name @type = type @nullable = nullable @primary_key = primary_key @default = default end def details if @details return @details end details = [] if !nullable? details.push("not null") end if has_default? details.push("default (#{default.inspect})") end if primary_key? details.push("primary key") end @details = details.join(", ") end def default if @default.nil? return nil end if type == "boolean" return !ActiveModel::Type::Boolean::FALSE_VALUES.include?(@default) end @default end def has_default? !default.nil? end def nullable? !!@nullable end def primary_key? !!@primary_key end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ahnnotate-0.2.0 | lib/ahnnotate/column.rb |