View Source Ash.CodeInterface (ash v2.9.11)

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

Link to this macro

define_interface(api, resource)

View Source (macro)

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)
end

Keep 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)
Link to this function

unwrap_calc_interface_args(keys, resource, arguments)

View Source