Skip to content

Instantly share code, notes, and snippets.

@the-spectator
Created September 2, 2020 04:33
Show Gist options
  • Save the-spectator/502e0ef860c1db4562a8d0d5c21d1327 to your computer and use it in GitHub Desktop.
Save the-spectator/502e0ef860c1db4562a8d0d5c21d1327 to your computer and use it in GitHub Desktop.
class User
STATUSES = [:active, :pending]
attr_accessor :status
def initialize(status = :pending)
@status = status
end
STATUSES.each do |value|
define_method(:"#{value}?") do
self.status == value
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment