Class: ActiveSupport::Deprecation
- Defined in:
- lib/maglev_record/maglev_support/active_support_patch.rb
Class Method Summary collapse
-
.deprecate_methods(target_module, *method_names) ⇒ Object
Declare that a method has been deprecated.
Class Method Details
.deprecate_methods(target_module, *method_names) ⇒ Object
Declare that a method has been deprecated.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/maglev_record/maglev_support/active_support_patch.rb', line 4 def deprecate_methods(target_module, *method_names) = method_names. method_names += .keys method_names.each do |method_name| next unless method_name.respond_to?(:to_sym) # next if Fixnum next if method_name == :none # check from rubygems/deprecate.rb next if method_name.to_s.include?(".") # . in method names is not allowed # workaround for :== if method_name.to_sym == :== method_name = "equal?" end target_module.alias_method_chain(method_name, :deprecation) do |target, punctuation| target_module.module_eval(<<-end_eval, __FILE__, __LINE__ + 1) def #{target}_with_deprecation#{punctuation}(*args, &block) ::ActiveSupport::Deprecation.warn( ::ActiveSupport::Deprecation.deprecated_method_warning( :#{method_name}, #{[method_name].inspect}), caller ) send(:#{target}_without_deprecation#{punctuation}, *args, &block) end end_eval end end end |