Sha256: 0ea734d0781244c7a8077a22d99e5ee6299b0acdc07c8d32c5cdfbe32ddf1f32

Contents?: true

Size: 821 Bytes

Versions: 11

Compression:

Stored size: 821 Bytes

Contents

module Rpush
  module Deprecatable
    def self.included(base)
      base.extend ClassMethods
    end

    module ClassMethods
      def deprecated(method_name, version, msg = nil)
        method_name_as_var = method_name.to_s.tr('=', '_setter_')
        instance_eval do
          alias_method "#{method_name_as_var}_without_warning", method_name
        end
        warning = "#{method_name} is deprecated and will be removed from Rpush #{version}."
        warning << " #{msg}" if msg
        class_eval(<<-RUBY, __FILE__, __LINE__)
          def #{method_name}(*args, &blk)
            trace = "\n\nCALLED FROM:\n" + caller.join("\n")
            Rpush::Deprecation.warn(#{warning.inspect} + trace)
            #{method_name_as_var}_without_warning(*args, &blk)
          end
        RUBY
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
rpush-2.3.2-java lib/rpush/deprecatable.rb
rpush-2.3.2 lib/rpush/deprecatable.rb
rpush-2.3.1-java lib/rpush/deprecatable.rb
rpush-2.3.1 lib/rpush/deprecatable.rb
rpush-2.3.0-java lib/rpush/deprecatable.rb
rpush-2.3.0 lib/rpush/deprecatable.rb
rpush-2.3.0.rc1 lib/rpush/deprecatable.rb
rpush-2.2.0-java lib/rpush/deprecatable.rb
rpush-2.2.0 lib/rpush/deprecatable.rb
rpush-2.1.0-java lib/rpush/deprecatable.rb
rpush-2.1.0 lib/rpush/deprecatable.rb