Module: Deprecations

Defined in:
lib/deprecations.rb,
lib/deprecations/version.rb,
lib/deprecations/behavior.rb,
lib/deprecations/extension.rb

Defined Under Namespace

Modules: ClassMethods, Helper, InstanceMethods, Raise, Warn

Constant Summary collapse

Error =
Class.new(ScriptError)
VERSION =
'2.2.0'

Class Method Summary collapse

Class Method Details

.behaviorObject



3
4
5
# File 'lib/deprecations/behavior.rb', line 3

def behavior
  BEHAVIOR.key(@behavior) || @behavior
end

.behavior=(behavior) ⇒ Object



7
8
9
# File 'lib/deprecations/behavior.rb', line 7

def behavior=(behavior)
  @behavior = as_behavior(behavior)
end

.call(subject, alternative, outdated) ⇒ Object



8
9
10
11
# File 'lib/deprecations.rb', line 8

def self.call(subject, alternative, outdated)
  @behavior.call(subject, alternative, outdated)
  self
end

.with_behavior(behavior) ⇒ Object Also known as: set_behavior

Raises:

  • (ArgumentError)


11
12
13
14
15
16
17
18
19
20
21
# File 'lib/deprecations/behavior.rb', line 11

def with_behavior(behavior)
  behavior = as_behavior(behavior)
  raise(ArgumentError, 'block expected') unless block_given?
  current_behavior = @behavior
  begin
    @behavior = behavior
    yield
  ensure
    @behavior = current_behavior
  end
end