I have class
House and module
Lockable. Locking and unlocking
House should reflect the real world, so you can't lock twice.
Do you think this is a good approach to using a module and raising an exception?
module Lockable attr_reader :locked def lock! raise StandardError, "Already locked" if @locked == true @locked = true end def unlock! raise StandardError, "Already unlocked" if @locked == false @locked = false end end class House include Lockable end
house = House.new house.lock! house.unlock! house.unlock! # raise an exception