Sha256: 0330e29594376c4d2a7a5254e5526ca1e82b241e27be0a66ab759b394ee46f6f

Contents?: true

Size: 1.4 KB

Versions: 24

Compression:

Stored size: 1.4 KB

Contents

module Protobuf
  module Deprecator

    def warn_deprecated(old_method, new_method)
      $stderr.puts %Q{[DEPRECATED] #{self.name}.#{old_method} is deprecated and will disappear in a future version.
              Please use #{self.name}.#{new_method} instead.\n}
    end

    # Given deprecations should be a hash whose keys are the new methods
    # and values are a list of deprecated methods that should send to t
    def deprecate_method(old_method, new_method)
      class_eval(<<-DEPRECATED, __FILE__, __LINE__ + 1)
        def #{old_method}(*args)
          warn_deprecated("#{old_method}", "#{new_method}")
          new_meth = method("#{new_method}")
          if new_meth.arity == 0
            __send__("#{new_method}")
          else
            __send__("#{new_method}", *args)
          end
        end
      DEPRECATED
    end

    # Given deprecations should be a hash whose keys are the new methods
    # and values are a list of deprecated methods that should send to t
    def deprecate_class_method(old_method, new_method)
      class_eval(<<-DEPRECATED, __FILE__, __LINE__ + 1)
        def self.#{old_method}(*args)
          warn_deprecated("#{old_method}", "#{new_method}")
          new_meth = method("#{new_method}")
          if new_meth.arity == 0
            __send__("#{new_method}")
          else
            __send__("#{new_method}", *args)
          end
        end
      DEPRECATED
    end

  end
end

Version data entries

24 entries across 24 versions & 2 rubygems

Version Path
protobuffy-3.6.0 lib/protobuf/deprecator.rb
protobuffy-3.5.1 lib/protobuf/deprecator.rb
protobuffy-3.4.0 lib/protobuf/deprecator.rb
protobuffy-3.3.0 lib/protobuf/deprecator.rb
protobuffy-3.2.0 lib/protobuf/deprecator.rb
protobuffy-3.1.0 lib/protobuf/deprecator.rb
protobuf-3.3.6 lib/protobuf/deprecator.rb
protobuf-3.3.5 lib/protobuf/deprecator.rb
protobuf-3.3.4 lib/protobuf/deprecator.rb
protobuf-3.3.3 lib/protobuf/deprecator.rb
protobuf-3.3.2 lib/protobuf/deprecator.rb
protobuf-3.3.1 lib/protobuf/deprecator.rb
protobuf-3.3.0 lib/protobuf/deprecator.rb
protobuf-3.2.1 lib/protobuf/deprecator.rb
protobuf-3.2.0 lib/protobuf/deprecator.rb
protobuf-3.1.0 lib/protobuf/deprecator.rb
protobuf-3.0.5 lib/protobuf/deprecator.rb
protobuf-3.0.4 lib/protobuf/deprecator.rb
protobuf-3.0.3 lib/protobuf/deprecator.rb
protobuf-3.0.2 lib/protobuf/deprecator.rb