View Source Ash.CodeInterface (ash v2.4.26)
Used to define the functions of a code interface for a resource.
Link to this section Summary
Functions
Defines the code interface for a given resource + api combination in the current module. For example
Link to this section Functions
Defines the code interface for a given resource + api combination in the current module. For example:
defmodule MyApp.Accounting do
  require Ash.CodeInterface
  Ash.CodeInterface.define_interface(MyApp.Accounting, MyApp.Accounting.Transaction)
  Ash.CodeInterface.define_interface(MyApp.Accounting, MyApp.Accounting.Account)
  Ash.CodeInterface.define_interface(MyApp.Accounting, MyApp.Accounting.Invoice)
endKeep in mind that you can have this "automatically" defined in your resources by using the define_for
flag in a resource.
For example:
defmodule MyApp.Accounting.Transaction do
  use Ash.Resource
  ...
  code_interface do
    define_for MyApp.Accounting
    define :start do
      args [:invoice_id]
    end
  end
end
# Which can now be used like so:
MyApp.Accounting.Transaction.start!(invoice.id)