Class: SleepingKingStudios::Tools::CoreTools
- Defined in:
- lib/sleeping_king_studios/tools/core_tools.rb
Overview
Tools for working with an application or working environment.
Defined Under Namespace
Classes: DeprecationError
Instance Attribute Summary collapse
-
#deprecation_strategy ⇒ String
readonly
The current deprecation strategy.
Instance Method Summary collapse
- #deprecate(*args, format: nil, message: nil) ⇒ Object
-
#empty_binding ⇒ Binding
Generates an empty Binding object with a BasicObject as the receiver.
-
#initialize(deprecation_strategy: nil) ⇒ CoreTools
constructor
A new instance of CoreTools.
-
#require_each(*file_patterns) ⇒ Object
Expands each file pattern and requires each file.
Methods inherited from Base
Constructor Details
#initialize(deprecation_strategy: nil) ⇒ CoreTools
Returns a new instance of CoreTools.
17 18 19 20 |
# File 'lib/sleeping_king_studios/tools/core_tools.rb', line 17 def initialize(deprecation_strategy: nil) @deprecation_strategy = deprecation_strategy || ENV.fetch('DEPRECATION_STRATEGY', 'warn') end |
Instance Attribute Details
#deprecation_strategy ⇒ String (readonly)
Returns The current deprecation strategy.
23 24 25 |
# File 'lib/sleeping_king_studios/tools/core_tools.rb', line 23 def deprecation_strategy @deprecation_strategy end |
Instance Method Details
#deprecate(name, message: nil) ⇒ Object #deprecate(*args, format: , message: nil) ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/sleeping_king_studios/tools/core_tools.rb', line 40 def deprecate(*args, format: nil, message: nil) send( :"deprecate_as_#{deprecation_strategy}", *args, format: format, message: ) end |
#empty_binding ⇒ Binding
Generates an empty Binding object with a BasicObject as the receiver.
52 53 54 55 56 57 58 59 60 |
# File 'lib/sleeping_king_studios/tools/core_tools.rb', line 52 def empty_binding context = Object.new def context.binding Kernel.instance_method(:binding).bind(self).call end context.binding end |
#require_each(*file_patterns) ⇒ Object
Expands each file pattern and requires each file.
65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/sleeping_king_studios/tools/core_tools.rb', line 65 def require_each(*file_patterns) file_patterns.each do |file_pattern| if file_pattern.include?('*') Dir[file_pattern].each do |file_name| Kernel.require file_name end else Kernel.require file_pattern end end end |