Vonagam
Vonagam
AEAsh Elixir
Created by rellen on 9/22/2023 in #support
pub_sub compilation issue
My bad, the option type checking was changed to use :wrap_list instead of a custom function. I've missed that the recursion was supported. Will revert the change.
5 replies
AEAsh Elixir
Created by Vonagam on 8/19/2023 in #support
Is there a way to define dsl for new type of attribute?
24 replies
AEAsh Elixir
Created by Vonagam on 8/19/2023 in #support
Is there a way to define dsl for new type of attribute?
So how do you feel about allowing Spark.Dsl.Patch.AddEntity even for patchable?: false sections (meaning by default) as long as addition's target matches one of preexisting entities target? I mean I can open a PR for that. I think there is nothing specific about attributes that they can be patchable in that sense and others can't.
24 replies
AEAsh Elixir
Created by Vonagam on 8/19/2023 in #support
Is there a way to define dsl for new type of attribute?
Hm... making attributes patchable might work in that scenario (without side-effects I hope). But they were not patchable before. And sections are not patchable by default. I assume that there is a reason for that. I have not looked deep into spark, but maybe validators/transformers will not know how to handle unexpected for them fields or something like that. If that not the reason then why sections are not patchable? As for macro approach, I would assume that autocomplete is not fixable, but supporting do end style can be done (it is macro after all). But requiring an author of a library to implement such behaviour does not seem user-friendly of spark. Maybe there should be an official util that helps with collecting spark-style options. Or maybe there is already a suitable method somewhere for that?
24 replies
AEAsh Elixir
Created by Vonagam on 8/19/2023 in #support
Is there a way to define dsl for new type of attribute?
Oh, I saw your thing but thought that it reuses and changes behaviour of uuid_primary_key. But I see that you have your own uuid_attribute. And the solution quite simple - just a macro that produces attribute call, cool. Thanks. Not that it is super important, but does such macro play well with Ash's autocomplete feature (where it provides available dsl sections/entries/options) or does it not? And looking at the code I assume such macro will not allow do end syntax for specifying options, only keyword list (again not that important, just assessing downsides, but it good to have a working option).
24 replies
AEAsh Elixir
Created by Robert Graff on 6/15/2023 in #support
Any examples of using can?
Looking at the code there is opts[:data] which is used as an initial record by update and destroy. So shorter version will be something like that:
MyApp.Users.can?({MyApp.Users.User, :update}, actor, data: target_user)
MyApp.Users.can?({MyApp.Users.User, :update}, actor, data: target_user)
Other actions do not need initial data, so that's why (I assume) it is only an option and not a supported form.
10 replies
AEAsh Elixir
Created by Robert Graff on 6/15/2023 in #support
Any examples of using can?
The problem here is {target_user, :update} I would assume that target_user is of type Ash.Resource.record(), but this is not supported. That form is for {User, :update} (so module of the resource, not the instance of it). To do what you want you can do something like this (can use pipes to shorten it):
changeset = Ash.Changeset.for_update(target_user, :update)
MyApp.Users.can?(changeset, actor)
changeset = Ash.Changeset.for_update(target_user, :update)
MyApp.Users.can?(changeset, actor)
10 replies