I love the block syntax for functions as it provides great readability and
I'm using it heavily as a design pattern to enclose code behind
authorization or caching.
For example:
function article_edit(params::Dict{Symbol,Any}; a::Article = Article())
with_authorization(:edit, unauthorized_access, params) do auth_scopes
article = SearchLight.is_persisted(a) ? a : SearchLight.find_one!!(
Article, params[:article_id])
ejl(:admin, :article, layout = :admin, article = article, params =
params) |> respond
end
end
I was wondering if there's any way to make the auth_scopes param optional
for the cases when the users are not interested in this passed value.
Similarly to how in the ruby blocks you're not required to capture the
values that are passed into, if you don't want them. It will help to
greatly reduce the noise, especially when multiple params are expected.