diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-02-03 16:00:59 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-02-03 16:00:59 -0800 |
commit | 89962d82f1f4c3d61d5851a4b0bca771357c6351 (patch) | |
tree | 4aff2d2e68b7456aeb2813d093239287fdb9c357 /activerecord | |
parent | dde8933d60d1c1890fef21237f0f328e0e34382b (diff) | |
download | rails-89962d82f1f4c3d61d5851a4b0bca771357c6351.tar.gz rails-89962d82f1f4c3d61d5851a4b0bca771357c6351.tar.bz2 rails-89962d82f1f4c3d61d5851a4b0bca771357c6351.zip |
refactor a bunch of return / if to a case / when
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/column.rb | 44 | ||||
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb | 12 |
2 files changed, 30 insertions, 26 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/column.rb b/activerecord/lib/active_record/connection_adapters/column.rb index beb06ea622..4e3d8a096f 100644 --- a/activerecord/lib/active_record/connection_adapters/column.rb +++ b/activerecord/lib/active_record/connection_adapters/column.rb @@ -238,28 +238,28 @@ module ActiveRecord def simplified_type(field_type) case field_type - when /int/i - :integer - when /float|double/i - :float - when /decimal|numeric|number/i - extract_scale(field_type) == 0 ? :integer : :decimal - when /datetime/i - :datetime - when /timestamp/i - :timestamp - when /time/i - :time - when /date/i - :date - when /clob/i, /text/i - :text - when /blob/i, /binary/i - :binary - when /char/i, /string/i - :string - when /boolean/i - :boolean + when /int/i + :integer + when /float|double/i + :float + when /decimal|numeric|number/i + extract_scale(field_type) == 0 ? :integer : :decimal + when /datetime/i + :datetime + when /timestamp/i + :timestamp + when /time/i + :time + when /date/i + :date + when /clob/i, /text/i + :text + when /blob/i, /binary/i + :binary + when /char/i, /string/i + :string + when /boolean/i + :boolean end end end diff --git a/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb index aaa2b33fcf..acf1832938 100644 --- a/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb @@ -45,10 +45,14 @@ module ActiveRecord private def simplified_type(field_type) return :boolean if Mysql2Adapter.emulate_booleans && field_type.downcase.index(BOOL) - return :string if field_type =~ /enum/i or field_type =~ /set/i - return :integer if field_type =~ /year/i - return :binary if field_type =~ /bit/i - super + + case field_type + when /enum/i, /set/i then :string + when /year/i then :integer + when /bit/i then :binary + else + super + end end def extract_limit(sql_type) |