Skip to content

Instantly share code, notes, and snippets.

@corroded
Created March 9, 2018 21:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save corroded/258b43d7c04ef65d9dc374654e9a635f to your computer and use it in GitHub Desktop.
Save corroded/258b43d7c04ef65d9dc374654e9a635f to your computer and use it in GitHub Desktop.
An initial example of the car crasher service object
# 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