Evaluation $LABEL inside of erb part in fixtures

Viewed 213

Looking for a way to DRY fixtures a bit. Let's say we have some data.yml. There is a part there, that can be referenced from $LABEL. Here is an exapmle:

DEFAULTS: &DEFAULTS
  state: $LABEL
  score: 99
one:
  <<: *DEFAULTS
  uuid: <%= ActiveRecord::FixtureSet.identify(:one, :uuid) %>
two:
  <<: *DEFAULTS
  uuid: <%= ActiveRecord::FixtureSet.identify(:two, :uuid) %>

Is there any way to DRY it. I want something like this:

DEFAULTS: &DEFAULTS
  state: $LABEL
  score: 99
  uuid: <%= ActiveRecord::FixtureSet.identify($LABEL, :uuid) %>
one:
  <<: *DEFAULTS
two:
  <<: *DEFAULTS

But it's not possible because $LABEL is not evaluated here. Any suggestions?

2 Answers
Related