Sha256: d1c309f5c37331bfe410f0e8059377360be51cfa4479a95a581bcc57c9935d9a

Contents?: true

Size: 844 Bytes

Versions: 1

Compression:

Stored size: 844 Bytes

Contents

#
# short inspect method on all objects.
#
# "abcdefghijklmnopabcdefghijklmnopabcdefghijklmnopabcdefghijklmnop".insp
#    -> "abcdefghijklmnopabcdefghijk..."
# Model.find(1).insp 
#    -> "<Model#1>"

module Deprecation
  def self.quiet
    @quiet = true
    yield
  ensure
    @quiet = false
  end

  def self.seen
    @seen ||= {}
  end
  
  def self.report(msg, instead=nil)
    return if App.env == "production"
    return if @quiet
    return if seen[[msg, instead]]

    seen[[msg, instead]] = true
    
    msg = "#{msg} is deprecated"
    msg += "; use #{instead} instead" if instead
    msg += ". From\n\t" + caller[1,4].join("\n\t")
    STDERR.puts msg
  end
end

module Deprecation::Etest
  def test_report
    STDERR.stubs(:puts).returns(nil)
    Deprecation.report "Hey"
    Deprecation.report "Hey"
  end
end if VEX_TEST == "base"

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vex-0.4.2 lib/vex/base/deprecation.rb