Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Conn#config instead of Conn#bag to store values needed by the extensions #29

Merged
merged 5 commits into from
Aug 5, 2019

Conversation

waiting-for-dev
Copy link
Owner

@waiting-for-dev waiting-for-dev commented Aug 5, 2019

This stops polluting Conn#bag hash keys. Conn#bag is intended for application level values, while Conn#config should contain configuration values that extensions may need.

This breaks :container, :dry_view and :dry_schema extensions, which were currently reading :container, :view_context and :param_sanitization_handler keys from Conn#bag. Besides, :view_context should now be a lambda accepting the Conn instance at the moment Conn#view is executed.

Specialized plugs for those three extensions which were used just for the purpose of adding needed keys to #bag have been removed. Instead, a WebPipe::Plug::Config now exists which can set in a single shot all settings provided:

plug :config, WebPipe::Plug::Config[
  container: MyContainer,
  view_context: (conn)-> { name: conn.fetch(:name) },
  param_sanitization_handler: (conn, result) { ... }
]

Remove dedicated plug to set the container.
Instead of returning a hash it must returb a lambda creating a hash from
`Conn`'s instance at the moment `#view` is called.

Remove dedicated plug to set view_context
Specialized plug to set the handler has been removed
@waiting-for-dev waiting-for-dev added the enhancement New feature or request label Aug 5, 2019
@waiting-for-dev waiting-for-dev merged commit 71d4ee6 into master Aug 5, 2019
@waiting-for-dev waiting-for-dev deleted the config branch August 5, 2019 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant