Created
September 2, 2020 04:33
-
-
Save the-spectator/502e0ef860c1db4562a8d0d5c21d1327 to your computer and use it in GitHub Desktop.
This file contains 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
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