rom-http
rom-http copied to clipboard
Possibility to set up config in relation's definition
Is there a way to set default params for current relation? I want to be able not to include these kind of lines
.with_base_path('users')
.add_params(expand: 'account,account_details')
everywhere in current relation...
This is not supported yet, you can just handle it on your own for now by storing a pre-configured relation somewhere and use that at run-time. We could add a feature that would make this simpler.
Got it. So for now I think I'll use it as:
class UsersRelation < ::ROM::Relation[:http]
# schema definition goes here
def by_id(id)
base.with_path(id.to_s)
end
def all
base.to_a
end
private
def base
with_base_path('users')
.add_params(expand: 'account,account_details')
end
end
I'll try to help, maybe with PR, when I get more time.