Skip to content

Instantly share code, notes, and snippets.

@theotherzach
Last active August 29, 2015 14:00
Show Gist options
  • Select an option

  • Save theotherzach/6dcc527821f9314133b7 to your computer and use it in GitHub Desktop.

Select an option

Save theotherzach/6dcc527821f9314133b7 to your computer and use it in GitHub Desktop.
class CustomerRepairOrder < RepairOrder
end
class Order < ActiveRecord::Base
end
class RecallRepairOrder < RepairOrder
def recall_date
#logic
end
end
class RepairOrder
def recall_date
""
end
end
class RepairOrderFactory
def self.build(data)
case data.type
when "warranty"
WarrantyRepairOrder
when "recall"
RecallRepairOrder
else
CustomerRepairOrder
end.new(data)
end
end
class RepairOrdersController < ApplicationController
def show
order = Order.find_by(id: params[:id])
@repair_order = RepairOrderFactory.build(order)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment