Skip to content

Instantly share code, notes, and snippets.

@joegaudet
Last active June 10, 2018 06:39
Show Gist options
  • Save joegaudet/38633aba95e633edd67e30d55deb8965 to your computer and use it in GitHub Desktop.
Save joegaudet/38633aba95e633edd67e30d55deb8965 to your computer and use it in GitHub Desktop.
Every . b ut the last should be treated as a file system '/'
class ClientController
dependency :assign_user, Clients::AssignUser
def assign_user
assign_user.(params[:user_id], params[:client_id])
end
end
module Application
module Clients
class AssignUser
dependency :get_user, Application::Users::Queries::Get
dependency :get_client, Application::Users::Queries::Get
def call(user_id, client_id)
user = get_user.(user_id)
client = get_client.(client_id)
client.admins << user
client.save!
client
end
end
end
end
module Application
module Clients
module Queries
class Get
dependency :client, Client
def call(id)
client.find(id)
end
end
end
end
end
module Application
module Users
module Queries
class Get
dependency :user, User
def call(id)
user.find(id)
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment