Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ex_machina help #5

Open
jeffdeville opened this issue Nov 8, 2016 · 0 comments
Open

ex_machina help #5

jeffdeville opened this issue Nov 8, 2016 · 0 comments

Comments

@jeffdeville
Copy link
Contributor

jeffdeville commented Nov 8, 2016

My ex_machina PR was rejected: beam-community/ex_machina#176 which is a shame, because I think it was a better strategy. But the only other workaround I've come up with is to create a custom strategy that hardcodes the tenants in the method names. If we can figure out how to make that work, it'd be nice to drop it in as a macro in an ex_machina factory

I've create this manually in my project, but I haven't actually needed test2 in my specs just yet to know if it works. :-)

defmodule RestConnectder.ExMachina.TenantStrategy do
  use ExMachina.Ecto, repo: RestConnectder.TenantRepo
  use ExMachina.Strategy, function_name: :insert_test
  use ExMachina.Strategy, function_name: :insert_test2
  import Tenantex.Queryable

  def handle_insert_test(record, _opts) do
    record |> set_tenant("test") |> insert
  end

  def handle_insert_test2(record, _opts) do
    record |> set_tenant("test2") |> insert
  end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant