File: deprecations.rb

package info (click to toggle)
ruby-liquid 5.11.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,372 kB
  • sloc: ruby: 14,164; makefile: 6
file content (22 lines) | stat: -rw-r--r-- 469 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# frozen_string_literal: true

require "set"

module Liquid
  class Deprecations
    class << self
      attr_accessor :warned

      Deprecations.warned = Set.new

      def warn(name, alternative)
        return if warned.include?(name)

        warned << name

        caller_location = caller_locations(2, 1).first
        Warning.warn("[DEPRECATION] #{name} is deprecated. Use #{alternative} instead. Called from #{caller_location}\n")
      end
    end
  end
end