Skip to content

Instantly share code, notes, and snippets.

@reedlaw
Created October 31, 2013 16:55
Show Gist options
  • Save reedlaw/7253130 to your computer and use it in GitHub Desktop.
Save reedlaw/7253130 to your computer and use it in GitHub Desktop.
Interactor class for interactors to inherit
class Interactor
attr_reader :request, :response
def initialize(request = {})
@request = request
@response = Response.new
end
private
def save_repository(repo_class)
if @request.params[:id]
repo = repo_class.find(@request.params[:id])
repo.update_attributes(@request.object_attributes)
else
repo = repo_class.create(@request.object_attributes)
end
repo
end
def delete(repo_class)
repo = repo_class.find(@request.params[:id])
repo.destroy
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment