lib/rb/lib/thrift/deprecation.rb
# Wraps the given methods to print a warning and call the real method
# Example:
#   deprecate! :readAll => :read_all
#--
# Yeah, this is ugly, passing a string to module_eval, but unfortunately
# using a block removes the ability to pass blocks to the defined method
# and breaks spec
Wraps the given methods to print a warning and call the real method
Example:
deprecate.

Yeah, this is ugly, passing a string to module_eval, but unfortunately
using a block removes the ability to pass blocks to the defined method
and breaks spec
Wraps the given methods to print a warning and call the real method Example : deprecate . Yeah this is ugly passing a string to module_eval but unfortunately using a block removes the ability to pass blocks to the defined method and breaks spec
def deprecate!(methods)
    return unless Thrift::DEPRECATION
    methods.each_pair do |old, new|
      module_eval <<-EOF
        def #{old}(*args, &block)
          old, new = #{[old,new].inspect}
          STDERR.puts "Warning: calling deprecated method \#{self.is_a?(Module) ? "\#{self}." : "\#{self.class}#"}\#{old}"
          STDERR.puts "  from \#{caller.first}"
          target = (self.is_a?(Module) ? (class << self;self;end) : self.class)
          target.send :define_method, old, target.instance_method(new) # unwrap
          target.instance_method(new).bind(self).call(*args, &block)
        end
      EOF
    end
  end
def deprecate! ( methods ) return unless Thrift :: DEPRECATION methods . each_pair do | old , new | module_eval <<-EOF 
        def  #{ old } (*args, &block)
          old, new =  #{ [ old , new ] . inspect } 
          STDERR.puts "Warning: calling deprecated method  \# {self.is_a?(Module) ? " \# {self}." : " \# {self.class}#"} \# {old}"
          STDERR.puts "  from  \# {caller.first}"
          target = (self.is_a?(Module) ? (class << self;self;end) : self.class)
          target.send :define_method, old, target.instance_method(new) # unwrap
          target.instance_method(new).bind(self).call(*args, &block)
        end
       EOF end end
Wraps the given methods to print a warning and call the real method
Example:
deprecate!
Wraps the given methods to print a warning and call the real method Example : deprecate!
methods
<not_specific>