Tools

A library of utility services and concerns.

Class: SleepingKingStudios::Tools::CoreTools

Parent Namespace
SleepingKingStudios::Tools
Inherited Classes
SleepingKingStudios::Tools::Base > Object
Defined In
lib/sleeping_king_studios/tools/core_tools.rb

Table Of Contents

Overview

Tools for working with an application or working environment.

Back To Top

Defined Under Namespace

Classes
DeprecationError

Back To Top

Class Methods

.instance => SleepingKingStudios::Tools::Base

Inherited From
SleepingKingStudios::Tools::Base

Returns

Back To Top

Constructor

#initialize(deprecation_caller_depth: nil, deprecation_strategy: nil) => CoreTools

Parameters

Returns

Back To Top

Instance Attributes

#deprecation_caller_depth => Integer (readonly)

Returns

#deprecation_strategy => String (readonly)

Returns

Back To Top

Instance Methods

#deprecate(name, message: nil) => Object
#deprecate(*args, format:, message: nil) => Object

Prints a deprecation warning or raises an exception.

The behavior of this method depends on the configured deprecation strategy, which can be passed to the constructor or configured using the DEPRECATION_STRATEGY environment variable.

Examples

CoreTools.deprecate 'ObjectTools#old_method'
#=> prints to stderr:
#
#   [WARNING] ObjectTools#old_method is deprecated.
#       called from /path/to/file.rb:4: in something_or_other

With An Additional Message

CoreTools.deprecate 'ObjectTools#old_method',
  'Use #new_method instead.'
#=> prints to stderr:
#
#   [WARNING] ObjectTools#old_method is deprecated. Use #new_method instead.
#     called from /path/to/file.rb:4: in something_or_other

With A Format String

CoreTools.deprecate 'ObjectTools#old_method',
  '0.1.0',
  format: '%s was deprecated in version %s.'
#=> prints to stderr:
#
#   ObjectTools#old_method was deprecated in version 0.1.0.
#     called from /path/to/file.rb:4: in something_or_other

Overloads

#deprecate(name, message: nil) => Object

Prints a deprecation warning or raises an exception.

Parameters
  • name (String) — the name of the object, method, or feature that has been deprecated.
  • message (String) — an optional message to print after the formatted string. Defaults to nil.
#deprecate(*args, format:, message: nil) => Object

Prints a deprecation warning with the specified format or raises.

Parameters
  • args (Array) — the arguments to pass into the format string.
  • format (String) — the format string.
  • message (String) — an optional message to print after the formatted string. Defaults to nil.

#empty_binding => Binding

Generates an empty Binding object with an Object as the receiver.

Returns

#require_each(*file_patterns) => Object

Expands each file pattern and requires each file.

Parameters

Back To Top


Back to Documentation | Reference | SleepingKingStudios | SleepingKingStudios::Tools