diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-09-09 09:08:27 +0100 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2011-09-13 00:01:57 +0100 |
commit | 99bd6b53da9555450afb1e050324007868e0768c (patch) | |
tree | b77bdc373a39b438613fda922057539029b882d6 /activemodel/lib/active_model/attribute_methods.rb | |
parent | 93d574c9627ade0b0bdf4ff05471dabe18cafedc (diff) | |
download | rails-99bd6b53da9555450afb1e050324007868e0768c.tar.gz rails-99bd6b53da9555450afb1e050324007868e0768c.tar.bz2 rails-99bd6b53da9555450afb1e050324007868e0768c.zip |
Add deprecation for doing `attribute_method_suffix ''`
Diffstat (limited to 'activemodel/lib/active_model/attribute_methods.rb')
-rw-r--r-- | activemodel/lib/active_model/attribute_methods.rb | 11 |
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}" |