Sha256: 9ea241ce7ff3fa5d837a9cb71409c6d153d88292cd13c103ec0fa449ad2c8c30

Contents?: true

Size: 685 Bytes

Versions: 56

Compression:

Stored size: 685 Bytes

Contents

class Ridgepole::DefaultsLimit
  DEFAULTS_LIMITS = {
    :mysql2 => {
      :boolean => 1,
      :integer => 4,
      :float   => 24,
      :string  => 255,
      :text    => 65535,
      :binary  => 65535,
    }
  }

  class << self
    def default_limit(column_type, options)
      defaults = DEFAULTS_LIMITS[adapter] || {}
      option_key = :"default_#{column_type}_limit"
      default_limit = options[option_key] || defaults[column_type] || 0
      default_limit.zero? ? nil : default_limit
    end

    def adapter
      ActiveRecord::Base.connection_config.fetch(:adapter).to_sym
    rescue ActiveRecord::ConnectionNotEstablished
      nil
    end
  end # of class methods
end

Version data entries

56 entries across 56 versions & 1 rubygems

Version Path
ridgepole-0.6.5.beta12 lib/ridgepole/default_limit.rb
ridgepole-0.6.5.beta11 lib/ridgepole/default_limit.rb
ridgepole-0.6.5.beta10 lib/ridgepole/default_limit.rb
ridgepole-0.6.5.beta9 lib/ridgepole/default_limit.rb
ridgepole-0.6.5.beta8 lib/ridgepole/default_limit.rb
ridgepole-0.6.5.beta7 lib/ridgepole/default_limit.rb
ridgepole-0.6.5.beta6 lib/ridgepole/default_limit.rb
ridgepole-0.6.5.beta5 lib/ridgepole/default_limit.rb
ridgepole-0.6.5.beta4 lib/ridgepole/default_limit.rb
ridgepole-0.6.5.beta3 lib/ridgepole/default_limit.rb
ridgepole-0.6.5.beta2 lib/ridgepole/default_limit.rb
ridgepole-0.6.5.beta lib/ridgepole/default_limit.rb
ridgepole-0.6.4 lib/ridgepole/default_limit.rb
ridgepole-0.6.4.beta9 lib/ridgepole/default_limit.rb
ridgepole-0.6.4.beta8 lib/ridgepole/default_limit.rb
ridgepole-0.6.4.beta7 lib/ridgepole/default_limit.rb
ridgepole-0.6.4.beta6 lib/ridgepole/default_limit.rb
ridgepole-0.6.4.beta5 lib/ridgepole/default_limit.rb
ridgepole-0.6.4.beta4 lib/ridgepole/default_limit.rb
ridgepole-0.6.4.beta3 lib/ridgepole/default_limit.rb