diff options
author | José Valim <jose.valim@gmail.com> | 2011-12-20 15:18:42 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-12-20 15:18:42 +0100 |
commit | 6a6fc4e1db2469bd309c074f607abb60764ba20d (patch) | |
tree | f25d87262f1a77ae9aea66543cf4e132d5bf7e3a /activesupport/lib | |
parent | 6c57177f2c7f4f934716d588545902d5fc00fa99 (diff) | |
download | rails-6a6fc4e1db2469bd309c074f607abb60764ba20d.tar.gz rails-6a6fc4e1db2469bd309c074f607abb60764ba20d.tar.bz2 rails-6a6fc4e1db2469bd309c074f607abb60764ba20d.zip |
Remove deprecations from Active Support.
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support.rb | 1 | ||||
-rw-r--r-- | activesupport/lib/active_support/concern.rb | 5 | ||||
-rw-r--r-- | activesupport/lib/active_support/memoizable.rb | 116 | ||||
-rw-r--r-- | activesupport/lib/active_support/message_encryptor.rb | 17 | ||||
-rw-r--r-- | activesupport/lib/active_support/message_verifier.rb | 5 |
5 files changed, 0 insertions, 144 deletions
diff --git a/activesupport/lib/active_support.rb b/activesupport/lib/active_support.rb index a5aeeacaef..896d0e5f65 100644 --- a/activesupport/lib/active_support.rb +++ b/activesupport/lib/active_support.rb @@ -62,7 +62,6 @@ module ActiveSupport autoload :Gzip autoload :Inflector autoload :JSON - autoload :Memoizable autoload :MessageEncryptor autoload :MessageVerifier autoload :Multibyte diff --git a/activesupport/lib/active_support/concern.rb b/activesupport/lib/active_support/concern.rb index af3da937c7..c94a8d99f4 100644 --- a/activesupport/lib/active_support/concern.rb +++ b/activesupport/lib/active_support/concern.rb @@ -109,11 +109,6 @@ module ActiveSupport @_dependencies.each { |dep| base.send(:include, dep) } super base.extend const_get("ClassMethods") if const_defined?("ClassMethods") - if const_defined?("InstanceMethods") - base.send :include, const_get("InstanceMethods") - ActiveSupport::Deprecation.warn "The InstanceMethods module inside ActiveSupport::Concern will be " \ - "no longer included automatically. Please define instance methods directly in #{base} instead.", caller - end base.class_eval(&@_included_block) if instance_variable_defined?("@_included_block") end end diff --git a/activesupport/lib/active_support/memoizable.rb b/activesupport/lib/active_support/memoizable.rb deleted file mode 100644 index 4c67676ad5..0000000000 --- a/activesupport/lib/active_support/memoizable.rb +++ /dev/null @@ -1,116 +0,0 @@ -require 'active_support/core_ext/kernel/singleton_class' -require 'active_support/core_ext/module/aliasing' -require 'active_support/deprecation' - -module ActiveSupport - module Memoizable - def self.extended(base) - ActiveSupport::Deprecation.warn "ActiveSupport::Memoizable is deprecated and will be removed in future releases," \ - "simply use Ruby memoization pattern instead.", caller - super - end - - def self.memoized_ivar_for(symbol) - "@_memoized_#{symbol.to_s.sub(/\?\Z/, '_query').sub(/!\Z/, '_bang')}".to_sym - end - - module InstanceMethods - def self.included(base) - base.class_eval do - unless base.method_defined?(:freeze_without_memoizable) - alias_method_chain :freeze, :memoizable - end - end - end - - def freeze_with_memoizable - memoize_all unless frozen? - freeze_without_memoizable - end - - def memoize_all - prime_cache ".*" - end - - def unmemoize_all - flush_cache ".*" - end - - def prime_cache(*syms) - syms.each do |sym| - methods.each do |m| - if m.to_s =~ /^_unmemoized_(#{sym})/ - if method(m).arity == 0 - __send__($1) - else - ivar = ActiveSupport::Memoizable.memoized_ivar_for($1) - instance_variable_set(ivar, {}) - end - end - end - end - end - - def flush_cache(*syms) - syms.each do |sym| - (methods + private_methods + protected_methods).each do |m| - if m.to_s =~ /^_unmemoized_(#{sym.to_s.gsub(/\?\Z/, '\?')})/ - ivar = ActiveSupport::Memoizable.memoized_ivar_for($1) - instance_variable_get(ivar).clear if instance_variable_defined?(ivar) - end - end - end - end - end - - def memoize(*symbols) - symbols.each do |symbol| - original_method = :"_unmemoized_#{symbol}" - memoized_ivar = ActiveSupport::Memoizable.memoized_ivar_for(symbol) - - class_eval <<-EOS, __FILE__, __LINE__ + 1 - include InstanceMethods # include InstanceMethods - # - if method_defined?(:#{original_method}) # if method_defined?(:_unmemoized_mime_type) - raise "Already memoized #{symbol}" # raise "Already memoized mime_type" - end # end - alias #{original_method} #{symbol} # alias _unmemoized_mime_type mime_type - # - if instance_method(:#{symbol}).arity == 0 # if instance_method(:mime_type).arity == 0 - def #{symbol}(reload = false) # def mime_type(reload = false) - if reload || !defined?(#{memoized_ivar}) || #{memoized_ivar}.empty? # if reload || !defined?(@_memoized_mime_type) || @_memoized_mime_type.empty? - #{memoized_ivar} = [#{original_method}] # @_memoized_mime_type = [_unmemoized_mime_type] - end # end - #{memoized_ivar}[0] # @_memoized_mime_type[0] - end # end - else # else - def #{symbol}(*args) # def mime_type(*args) - #{memoized_ivar} ||= {} unless frozen? # @_memoized_mime_type ||= {} unless frozen? - args_length = method(:#{original_method}).arity # args_length = method(:_unmemoized_mime_type).arity - if args.length == args_length + 1 && # if args.length == args_length + 1 && - (args.last == true || args.last == :reload) # (args.last == true || args.last == :reload) - reload = args.pop # reload = args.pop - end # end - # - if defined?(#{memoized_ivar}) && #{memoized_ivar} # if defined?(@_memoized_mime_type) && @_memoized_mime_type - if !reload && #{memoized_ivar}.has_key?(args) # if !reload && @_memoized_mime_type.has_key?(args) - #{memoized_ivar}[args] # @_memoized_mime_type[args] - elsif #{memoized_ivar} # elsif @_memoized_mime_type - #{memoized_ivar}[args] = #{original_method}(*args) # @_memoized_mime_type[args] = _unmemoized_mime_type(*args) - end # end - else # else - #{original_method}(*args) # _unmemoized_mime_type(*args) - end # end - end # end - end # end - # - if private_method_defined?(#{original_method.inspect}) # if private_method_defined?(:_unmemoized_mime_type) - private #{symbol.inspect} # private :mime_type - elsif protected_method_defined?(#{original_method.inspect}) # elsif protected_method_defined?(:_unmemoized_mime_type) - protected #{symbol.inspect} # protected :mime_type - end # end - EOS - end - end - end -end diff --git a/activesupport/lib/active_support/message_encryptor.rb b/activesupport/lib/active_support/message_encryptor.rb index 9ef2b29580..7d8a7fb687 100644 --- a/activesupport/lib/active_support/message_encryptor.rb +++ b/activesupport/lib/active_support/message_encryptor.rb @@ -24,29 +24,12 @@ module ActiveSupport OpenSSLCipherError = OpenSSL::Cipher.const_defined?(:CipherError) ? OpenSSL::Cipher::CipherError : OpenSSL::CipherError def initialize(secret, options = {}) - unless options.is_a?(Hash) - ActiveSupport::Deprecation.warn "The second parameter should be an options hash. Use :cipher => 'algorithm' to specify the cipher algorithm." - options = { :cipher => options } - end - @secret = secret @cipher = options[:cipher] || 'aes-256-cbc' @verifier = MessageVerifier.new(@secret, :serializer => NullSerializer) @serializer = options[:serializer] || Marshal end - def encrypt(value) - ActiveSupport::Deprecation.warn "MessageEncryptor#encrypt is deprecated as it is not safe without a signature. " \ - "Please use MessageEncryptor#encrypt_and_sign instead." - _encrypt(value) - end - - def decrypt(value) - ActiveSupport::Deprecation.warn "MessageEncryptor#decrypt is deprecated as it is not safe without a signature. " \ - "Please use MessageEncryptor#decrypt_and_verify instead." - _decrypt(value) - end - # Encrypt and sign a message. We need to sign the message in order to avoid padding attacks. # Reference: http://www.limited-entropy.com/padding-oracle-attacks def encrypt_and_sign(value) diff --git a/activesupport/lib/active_support/message_verifier.rb b/activesupport/lib/active_support/message_verifier.rb index 9d7c81142a..30ac44f6fa 100644 --- a/activesupport/lib/active_support/message_verifier.rb +++ b/activesupport/lib/active_support/message_verifier.rb @@ -27,11 +27,6 @@ module ActiveSupport class InvalidSignature < StandardError; end def initialize(secret, options = {}) - unless options.is_a?(Hash) - ActiveSupport::Deprecation.warn "The second parameter should be an options hash. Use :digest => 'algorithm' to specify the digest algorithm." - options = { :digest => options } - end - @secret = secret @digest = options[:digest] || 'SHA1' @serializer = options[:serializer] || Marshal |