Class: Ridgepole::DefaultsLimit
- Inherits:
-
Object
- Object
- Ridgepole::DefaultsLimit
- Defined in:
- lib/ridgepole/default_limit.rb
Constant Summary collapse
- DEFAULTS_LIMITS =
{ mysql2: { boolean: 1, integer: 4, bigint: 8, float: 24, string: 255, text: 65_535, binary: 65_535, }, }.freeze
Class Method Summary collapse
Class Method Details
.adapter ⇒ Object
25 26 27 28 29 |
# File 'lib/ridgepole/default_limit.rb', line 25 def adapter ActiveRecord::Base.connection.adapter_name.downcase.to_sym rescue ActiveRecord::ConnectionNotEstablished nil end |
.default_limit(column_type, options) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/ridgepole/default_limit.rb', line 18 def default_limit(column_type, ) defaults = DEFAULTS_LIMITS[adapter] || {} option_key = :"default_#{column_type}_limit" default_limit = [option_key] || defaults[column_type] || 0 default_limit.zero? ? nil : default_limit end |