annotation on target_rule_name
Closed this issue · 2 comments
codalogic commented
I've been putting together some ideas on using annotations and directives for specifying additional constraints (https://github.com/codalogic/JCR-Co-Constraints). It looks like it would be helpful to be able to include annotations on target_rule_name!
I've come up with an example of:
report {
"type" @{id t} : "string",
( @{when $t == "boot"} boot-details |
@{when $t == "shutdown"} shutdown-details |
default-details )
}
where boot-details
, shutdown-details
and default-details
are groups that are effectively mixins to be selected based on the value of the type
member.
Hopefully it's a simple fix to do:
rule(:target_rule_name) { annotations >> ((ruleset_id_alias >> str('.')).maybe >> rule_name).as(:target_rule_name) }
#! target_rule_name = annotations [ ruleset_id_alias "." ] rule_name
If you have no objections I'll make it so...
anewton1998 commented
Interesting and useful use case. Yes, let's do it.
codalogic commented
Done. Pull request submitted.
(I might create another *_spec.rb file to check I can actually parse what I'm suggesting with the co-constraints stuff.)