Skip to content

Instantly share code, notes, and snippets.

@mariusz-blaszczak
Created August 28, 2018 10:11
Show Gist options
  • Save mariusz-blaszczak/7f7876681849ad6bb921d8ab22fe1d32 to your computer and use it in GitHub Desktop.
Save mariusz-blaszczak/7f7876681849ad6bb921d8ab22fe1d32 to your computer and use it in GitHub Desktop.
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