Skip to content

Use a function to lookup values in resource definition #118

@ordnungswidrig

Description

@ordnungswidrig

Motivation #115 (comment)

Use a new function to lookup values from resource definitions to

  • ensure uniform invocation of functions that are specified in a resource definition. The signature of the functions must be f :: context-map -> any
  • drop premature conversion of the resource map values to functions. This prevents inspection of the resource definition at runtime because values have be replaced by cryptic anonymous functions

Provposed implementation:

(defn lookup-resource [ctx key]
  (let [v (get-in ctx [:resource key])]
    (if (fn? v) (v ctx) v)

I'm not sure about the name and whether (defn lookup-resource [resource key context]) would be more explicit. However, the later variant is redundant because the resource is always available in the context.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions