Class: Configurations::BlankObject
- Inherits:
- BasicObject
- Defined in:
- lib/configurations/blank_object.rb
Overview
Create a blank object with some kernel methods
Direct Known Subclasses
Constant Summary collapse
- KEEP_METHODS =
The instance methods to keep on the blank object.
[ :equal?, :object_id, :__id__, :__send__, :method_missing ].freeze
- ALIAS_KERNEL_METHODS =
The kernel methods to alias to an internal name
{ __class__: :class, __instance_eval__: :instance_eval, __define_singleton_method__: :define_singleton_method }.freeze
- KEEP_KERNEL_METHODS =
The kernel methods to keep on the blank object
[ :respond_to?, :is_a?, :inspect, :object_id, # rbx needs the singleton class to access singleton methods :singleton_class, *ALIAS_KERNEL_METHODS.keys ].freeze
Class Method Summary collapse
-
.blank_kernel ⇒ Module
A Kernel module with only the methods defined in KEEP_KERNEL_METHODS.
Class Method Details
.blank_kernel ⇒ Module
Returns A Kernel module with only the methods defined in KEEP_KERNEL_METHODS.
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/configurations/blank_object.rb', line 44 def self.blank_kernel kernel = ::Kernel.dup ALIAS_KERNEL_METHODS.each do |new_name, old_name| kernel.module_eval { alias_method new_name, old_name } end (kernel.instance_methods - KEEP_KERNEL_METHODS).each do |method| kernel.module_eval { undef_method method } end kernel end |