Created
March 9, 2018 21:00
-
-
Save corroded/258b43d7c04ef65d9dc374654e9a635f to your computer and use it in GitHub Desktop.
An initial example of the car crasher service object
This file contains hidden or 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
# frozen_string_literal: true | |
module Vehicle | |
class Crasher | |
def initialize(vehicle) | |
@vehicle = vehicle | |
end | |
def run | |
return if vehicle.parked? || vehicle.stalled? | |
vehicle.update_attributes(state: 'stalled') | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment