diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-05-18 17:02:55 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-05-18 17:02:55 -0300 |
commit | 9c4487517c90dad572502983779898058432a837 (patch) | |
tree | 95c5abe7209da0ed147086e37ca5309b3745e358 /activerecord | |
parent | 3442ba484911f6c47131cfae11c5a2845533f075 (diff) | |
parent | 8a89a238968fbae4ec5b899703794115c2ca33e6 (diff) | |
download | rails-9c4487517c90dad572502983779898058432a837.tar.gz rails-9c4487517c90dad572502983779898058432a837.tar.bz2 rails-9c4487517c90dad572502983779898058432a837.zip |
Merge pull request #20187 from yui-knk/refactor/type_int
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 |