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 => 65535, :binary => 65535, } }
Class Method Summary collapse
Class Method Details
.adapter ⇒ Object
22 23 24 25 26 |
# File 'lib/ridgepole/default_limit.rb', line 22 def adapter ActiveRecord::Base.connection_config.fetch(:adapter).to_sym rescue ActiveRecord::ConnectionNotEstablished nil end |
.default_limit(column_type, options) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/ridgepole/default_limit.rb', line 15 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 |