Module: R2OAS::Deprecation::Reporting

Included in:
R2OAS::Deprecation
Defined in:
lib/r2-oas/support/deprecation/reporting.rb

Constant Summary collapse

FILE_LINE_METHOD_REGEXP =
/^(?<file>.+?):(?<line>\d+)(?::in `(?<method>.*?)')?/.freeze
R2OAS_GEM_ROOT =
File.expand_path('../../../../', __dir__) + '/lib'

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#gem_nameObject

Returns the value of attribute gem_name.



8
9
10
# File 'lib/r2-oas/support/deprecation/reporting.rb', line 8

def gem_name
  @gem_name
end

#silencedObject

Returns the value of attribute silenced.



8
9
10
# File 'lib/r2-oas/support/deprecation/reporting.rb', line 8

def silenced
  @silenced
end

Instance Method Details

#silenceObject



23
24
25
26
27
28
# File 'lib/r2-oas/support/deprecation/reporting.rb', line 23

def silence
  old_silenced = silenced
  self.silenced = true
  yield if block_given?
  self.silenced = old_silenced
end

#warn(message = nil, callstack = nil) ⇒ Object Also known as: will_remove



13
14
15
16
17
18
19
20
# File 'lib/r2-oas/support/deprecation/reporting.rb', line 13

def warn(message = nil, callstack = nil)
  return if silenced

  callstack ||= caller_locations(2)
  deprecation_message(callstack, message).tap do |msg|
    behavior.each { |b| b.call(msg, callstack, deprecation_horizon, gem_name) }
  end
end