diff options
author | yui-knk <spiketeika@gmail.com> | 2015-05-18 21:29:22 +0900 |
---|---|---|
committer | yui-knk <spiketeika@gmail.com> | 2015-05-18 21:29:22 +0900 |
commit | 8a89a238968fbae4ec5b899703794115c2ca33e6 (patch) | |
tree | 72ac862550205a2d88c13c460fa1d120f911f12a /activerecord | |
parent | 41e5e8982bdff21db39b673363c42a75995d1880 (diff) | |
download | rails-8a89a238968fbae4ec5b899703794115c2ca33e6.tar.gz rails-8a89a238968fbae4ec5b899703794115c2ca33e6.tar.bz2 rails-8a89a238968fbae4ec5b899703794115c2ca33e6.zip |
Refactoring `ActiveRecord::Type::Integer` limit
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/type/integer.rb | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/type/integer.rb b/activerecord/lib/active_record/type/integer.rb index 2a1b04ac7f..c5040c6d3b 100644 --- a/activerecord/lib/active_record/type/integer.rb +++ b/activerecord/lib/active_record/type/integer.rb @@ -46,18 +46,21 @@ module ActiveRecord def ensure_in_range(value) unless range.cover?(value) - raise RangeError, "#{value} is out of range for #{self.class} with limit #{limit || DEFAULT_LIMIT}" + raise RangeError, "#{value} is out of range for #{self.class} with limit #{_limit}" end end def max_value - limit = self.limit || DEFAULT_LIMIT - 1 << (limit * 8 - 1) # 8 bits per byte with one bit for sign + 1 << (_limit * 8 - 1) # 8 bits per byte with one bit for sign end def min_value -max_value end + + def _limit + self.limit || DEFAULT_LIMIT + end end end end |