snusnu / ramom

relational algebra meets object mapping
MIT License
6 stars 0 forks source link

Support empty base names in Naming::NaturalJoin #17

Closed snusnu closed 9 years ago

snusnu commented 9 years ago

Originally filed at https://github.com/snusnu/mom/issues/5

Turns out mom is not the cause of the issue as it just passes the unmodified prefix on to the injected name_generator (e.g. Ramom::Naming::NaturalJoin) which in turn incorrectly handles empty string prefixes.

Given mom's contract of simply passing on the prefix, it is any name_generator's responsibility to expect more or less "arbitrary" values. In Ramom::Naming::NaturalJoin specifically, this means that expecting prefix == false in addition to prefix == '' is beneficial from an end user API pov.

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

looks way better (more intuitive) than

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