aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2011-09-09 09:08:27 +0100
committerJon Leighton <j@jonathanleighton.com>2011-09-13 00:01:57 +0100
commit99bd6b53da9555450afb1e050324007868e0768c (patch)
treeb77bdc373a39b438613fda922057539029b882d6 /activemodel/lib/active_model
parent93d574c9627ade0b0bdf4ff05471dabe18cafedc (diff)
downloadrails-99bd6b53da9555450afb1e050324007868e0768c.tar.gz
rails-99bd6b53da9555450afb1e050324007868e0768c.tar.bz2
rails-99bd6b53da9555450afb1e050324007868e0768c.zip
Add deprecation for doing `attribute_method_suffix ''`
Diffstat (limited to 'activemodel/lib/active_model')
-rw-r--r--activemodel/lib/active_model/attribute_methods.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/activemodel/lib/active_model/attribute_methods.rb b/activemodel/lib/active_model/attribute_methods.rb
index b1724c277a..c5f7a21d3f 100644
--- a/activemodel/lib/active_model/attribute_methods.rb
+++ b/activemodel/lib/active_model/attribute_methods.rb
@@ -1,5 +1,6 @@
require 'active_support/core_ext/hash/keys'
require 'active_support/core_ext/class/attribute'
+require 'active_support/deprecation'
module ActiveModel
class MissingAttributeError < NoMethodError
@@ -365,6 +366,16 @@ module ActiveModel
def initialize(options = {})
options.symbolize_keys!
+
+ if options[:prefix] == '' || options[:suffix] == ''
+ ActiveSupport::Deprecation.warn(
+ "Specifying an empty prefix/suffix for an attribute method is no longer " \
+ "necessary. If the un-prefixed/suffixed version of the method has not been " \
+ "defined when `define_attribute_methods` is called, it will be defined " \
+ "automatically."
+ )
+ end
+
@prefix, @suffix = options[:prefix] || '', options[:suffix] || ''
@regex = /^(#{Regexp.escape(@prefix)})(.+?)(#{Regexp.escape(@suffix)})$/
@method_missing_target = "#{@prefix}attribute#{@suffix}"