Skip to content

Instantly share code, notes, and snippets.

@jtzero
Last active September 16, 2024 18:26
Show Gist options
  • Save jtzero/d4b3a3646bb55bf1586e3296a1e47332 to your computer and use it in GitHub Desktop.
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
# 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