Skip to content

Instantly share code, notes, and snippets.

@ys
Created August 29, 2012 12:29
Show Gist options
  • Save ys/3511791 to your computer and use it in GitHub Desktop.
Save ys/3511791 to your computer and use it in GitHub Desktop.
Service Layer kind of
class ProjectController < ApplicationController
def create
service_layer.save(project)
end
private
def service_layer
@service_layer ||= ServiceLayer.instance
end
end
class ServiceLayer
def self.instance
@service_layer ||= new
end
end
@beanieboi
Copy link

just include Singleton in the ServiceLayer class and you get the same behavior

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment