Skip to content

Repository files navigation

AshReqOpt

Shortcut DSL for attributes and relationships in Ash resources.

For attribute

DSLallow_nil?public?
attribute (Ash)truefalse
reqfalsetrue
req_prvfalsefalse
opttruetrue
opt_prvtruefalse

For belongs_to

DSLallow_nil?public?
belongs_to (Ash)truefalse
req_belongs_tofalsetrue
req_prv_belongs_tofalsefalse
opt_belongs_totruetrue
opt_prv_belongs_totruefalse

Usage Example

defmoduleMyApp.UserdouseAsh.Resource,extensions: [AshReqOpt]attributesdouuid_primary_key:id# Required attributesreq:email,:string# allow_nil?: false, public?: truereq_prv:password_hash,:string# allow_nil?: false, public?: false# Optional attributesopt:name,:string# allow_nil?: true, public?: trueopt_prv:last_login_at,:utc_datetime# allow_nil?: true, public?: false# Original attribute macro still worksattribute:nickname,:string,allow_nil?: trueendrelationshipsdo# Required relationshipsreq_belongs_to:company,Company# allow_nil?: false, public?: truereq_prv_belongs_to:created_by,User# allow_nil?: false, public?: false# Optional relationshipsopt_belongs_to:manager,User# allow_nil?: true, public?: trueopt_prv_belongs_to:updated_by,User# allow_nil?: true, public?: false# Original belongs_to macro still worksbelongs_to:department,Department,allow_nil?: trueendend

Installation

Add ash_req_opt to your list of dependencies in mix.exs:

defdepsdo[{:ash_req_opt,"~> 0.2.0"}]end

License

MIT

About

No description, website, or topics provided.

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages