You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
moduleOnyx::SQLmacrorestrict(t, model, &block)
{%for exp in block.body.expressions %}
{%unless exp.is_a?(Call) && exp.name =="getter"%}
{%raise"Must be getter"%}
{%end%}
{% found =false%}
{%for method in t.methods %}
{%if method.name == exp.args.first.var &&
method.return_type == exp.args.first.type %}
{% found =true%}
{%end%}
{%end%}
{%raise"#{model} is restricted to have `#{exp.args.first.var}` getter with return type `#{exp.args.first.type}`"unless found %}
{%end%}
endendclassUserproperty id : Int32?
property name : String?
definitialize(@id=nil, @name=nil)
endenddeffoo(user : T) forallTOnyx::SQL.restrict({{T}}, User) dogetter id : Int32getter name : String?
end
pp user
end
record UserObject, id : Int32, name : String?
# foo(UserObject.new(42, nil)) # OK
foo(User.new(42, nil)) # User is restricted to have `id` getter with return type `Int32`
The text was updated successfully, but these errors were encountered:
Just an idea.
The text was updated successfully, but these errors were encountered: