Skip to content

Instantly share code, notes, and snippets.

@noelrappin
Last active February 17, 2023 00:02
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save noelrappin/9b2dfcd84bf3d5082f69bfc8189907f0 to your computer and use it in GitHub Desktop.
Save noelrappin/9b2dfcd84bf3d5082f69bfc8189907f0 to your computer and use it in GitHub Desktop.
Sigilize
class Module
def sigilize(method_name)
define_method("#{method_name}?") do |*args, **kwargs|
!!method_name(*args, **kwargs)
end
define_method("#{method_name}!") do |*args, **kwargs|
result = method_name(*args, **kwargs)
raise StandardError unless result
result
end
end
end
## Usage
class Process
def status
#whatever
end
sigilize(:status)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment