Created
August 28, 2018 10:11
-
-
Save mariusz-blaszczak/7f7876681849ad6bb921d8ab22fe1d32 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 Doors | |
def self.close! | |
DoorsEvent.create(state: DoorsEvent.states[:closed]) | |
end | |
def self.open! | |
DoorsEvent.create(state: DoorsEvent.states[:open]) | |
end | |
def self.toggle! | |
return self.close! if self.open? | |
self.open! | |
end | |
def self.open? | |
DoorsEvent.last.open? | |
end | |
def self.last_event | |
DoorsEvent.last | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment