Sha256: 588a351f7ecdd32350c03685ed19b026ed1c0da2cd231fa9cc419018409d6b83
Contents?: true
Size: 817 Bytes
Versions: 3
Compression:
Stored size: 817 Bytes
Contents
module Automigration class DbColumn < Struct.new(:name, :type, :options) def initialize(name_, type_, options_) super options_.assert_valid_keys(:default, :null, :limit, :scale, :precision) end def self.from_activerecord_column(column) out = DbColumn.new(column.name.to_sym, column.type.to_sym, { :default => column.default, :null => column.null, :limit => column.limit, :scale => column.scale, :precision => column.precision }) end def the_same?(other) (__to_array <=> other.send(:__to_array)) == 0 end def to_options options.reject{|k, v| k != :default && v.nil?} end private # compare only by 3 values def __to_array [name.to_s, type.to_s, options[:default].to_s] end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
automigration-1.1.4 | lib/automigration/db_column.rb |
automigration-1.1.3 | lib/automigration/db_column.rb |
automigration-1.1.2 | lib/automigration/db_column.rb |