Last active
September 16, 2024 18:26
-
-
Save jtzero/d4b3a3646bb55bf1586e3296a1e47332 to your computer and use it in GitHub Desktop.
tests to see is an entity is a BasicObject as a BasicObject instanance does not respond to #is_a? or #class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Kernel === BasicObject #=> true | |
# Kernel === BasicObject.new #=> false | |
# Kernel === Object.new #=> true | |
# rubocop:disable Style/YodaCondition | |
# can't rely on an unknown object to respond | |
# to the right messages | |
def self.is_a_basic_object?(entity) | |
BasicObject != entity && (!Kernel === entity) | |
end | |
# rubocop:enable Style/YodaCondition |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment