Sha256: a192d1c53220e97786270ddb144886d0a0e795a08e037e0d6c37a0d408d6458c
Contents?: true
Size: 1.53 KB
Versions: 3
Compression:
Stored size: 1.53 KB
Contents
module Valle module AbstractAdapter class ColumnWrapper class << self ## # Wraps original column # # @param [ActiveRecord::ConnectionAdapters::Column] original_column the original column # def wrap(original_column) case when limit_in_bytes?(original_column) ByteLimitedColumn.new(original_column) when limit_in_characters?(original_column) CharacterLimitedColumn.new(original_column) else UnlimitedColumn.new(original_column) end end private ## # Determines whether the limit's method returned value is count of bytes # # Limit is number of bytes for :binary and :integer columns. # @see http://apidock.com/rails/ActiveRecord/ConnectionAdapters/TableDefinition/column # def limit_in_bytes?(column) case column.type when :primary_key; true # when :binary; true when :integer; true else false end end ## # Determines whether the limit's method returned value is count of characters # # Limit is number of characters for :string and :text columns # @see http://apidock.com/rails/ActiveRecord/ConnectionAdapters/TableDefinition/column # def limit_in_characters?(column) case column.type when :string; true when :text; true else false end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
valle-0.2.0 | lib/valle/abstract_adapter/column_wrapper.rb |
valle-0.1.0 | lib/valle/abstract_adapter/column_wrapper.rb |
valle-0.0.3 | lib/valle/abstract_adapter/column_wrapper.rb |