snusnu/mom

Support empty attribute prefixes

Closed this issue · 1 comments

When working with a definition registry that uses a name generator to generate attribute names, it's sometimes desirable to "skip" the renaming that would otherwise be applied to every attribute. It seems that the most easiest way to achieve this would be to have a definition's :prefix option support an EMPTY_STRING. Currently, attribute naming is "broken" when an empty string gets used (it still prepends _ to the attribute name in question, which definitely should be considered a bug).

Instead of having to do this:

register :page_info do
  map :number, from: :number
  map :limit , from: :limit
  map :total , from: :total
end

we should be able to do this:

register :page_info, prefix: EMPTY_STRING do
  map :number
  map :limit
  map :total
end

Fixed upstream, respecting mom's contract of simply passing on the unmodified prefix as it was given by a user.