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
23 24 25 26 27 |
# File 'lib/ridgepole/default_limit.rb', line 23 def adapter ActiveRecord::Base.connection_config.fetch(:adapter).to_sym rescue ActiveRecord::ConnectionNotEstablished nil end |
.default_limit(column_type, options) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/ridgepole/default_limit.rb', line 16 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 |