rom-rb / rom

Data mapping and persistence toolkit for Ruby
https://rom-rb.org
MIT License
2.08k stars 161 forks source link

Deprecate register_as and dataset class settings #414

Closed solnic closed 7 years ago

solnic commented 7 years ago

We should be using schemas as the source of information about dataset names, relation aliases and attributes, because this type of consistency is simpler and we'll reduce the risk of having weird bugs. This is how it works already to some extent, but we're not 100% there yet.

With rom 4.0 we should remove register_as and dataset settings from relation's ClassInterface because it's redundant. Schemas should be responsible for building relation name objects (which means they will include dataset name, relation name and have the ability to alias relations at runtime too).

In code this means:

module Relations
  class Users < ROM::Relation[:sql]
    # this must go away
    register_as :users
    dataset :people

    # in favor of this (which is already implemented)
    schema(:people, as: :users, infer: true)
  end
end

TODO