aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2015-05-18 17:02:55 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2015-05-18 17:02:55 -0300
commit9c4487517c90dad572502983779898058432a837 (patch)
tree95c5abe7209da0ed147086e37ca5309b3745e358 /activerecord
parent3442ba484911f6c47131cfae11c5a2845533f075 (diff)
parent8a89a238968fbae4ec5b899703794115c2ca33e6 (diff)
downloadrails-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.rb9
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