class Sass::Script::CssVariableWarning

An object tracking whether a warning has been emitted for a given script tree.

This is shared among all objects in a script tree. Whenever any of those objects encounters a situation in which it wouldn't produce semantically identical CSS to its input, it calls {#warn!}. The first time {#warn!} is called for a given warning object, it prints a deprecation warning.

Public Class Methods

new() click to toggle source
# File lib/sass/script/css_variable_warning.rb, line 11
def initialize
  @warned = false
  @value = nil
end

Public Instance Methods

value=(value) click to toggle source

Sets the root of the script tree that this warning refers to.

@param value [Sass::Script::Tree::Node]

# File lib/sass/script/css_variable_warning.rb, line 19
def value=(value)
  warn_called = @warned && !@value
  @value = value
  print_warning if warn_called
end
warn!() click to toggle source

The first time this is called, it prints a deprecation warning.

This may be called before {#value=}. If it is, the warning is emitted once the script tree is set.

# File lib/sass/script/css_variable_warning.rb, line 29
def warn!
  return if @warned
  @warned = true
  return unless @value

  print_warning
end