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

Reduce dependencies on I18nRenderer #2076

Merged
merged 6 commits into from
Nov 13, 2015

Conversation

floehopper
Copy link
Contributor

I want to be able to change the SmartAnswer::QuestionPresenter to use the SmartAnswer::ErbRenderer instead of the SmartAnswer::I18nRenderer and so anything I can do to reduce the dependencies on the I18nRenderer will make this easier.

Expected observable changes

  • None

@chrisroos
Copy link
Contributor

I've left a couple of small comments but in general this looks good to me.

@chrisroos chrisroos self-assigned this Nov 13, 2015
@chrisroos chrisroos added the LGTM label Nov 13, 2015
I want to be able to change the `SmartAnswer::QuestionPresenter` to use the
`SmartAnswer::ErbRenderer` and so anything I can do to reduce the dependencies
on the `I18nRenderer` will make this easier.

This commit introduces a little duplication in the question presenter
sub-classes. I plan to fix that in a later commit.
I want to be able to change the `SmartAnswer::QuestionPresenter` to use the
`SmartAnswer::ErbRenderer` and so anything I can do to reduce the dependencies
on the `I18nRenderer` will make this easier.
I want to use this helper for formatting values in questions, so I've made the
name more generic.
The `SmartAnswer::FormattingHelper` had an implicit dependency on
`ActionView::Helpers::NumberHelper`.

This helper is currently only being used in the `SmartAnswer::ErbRenderer`
which includes it and the `ActionView::Helpers::NumberHelper` into the view
object, thus satisfying the implicit dependency.

I want to use this helper from within some of the sub-classes of
`QuestionPresenter`. Including `ActionView::Helpers::NumberHelper` explicitly
should make this easier.

I've left `ActionView::Helpers::NumberHelper` being included into the view,
because there is code in some templates which use methods on this module
directly i.e. not via `SmartAnswer::FormattingHelper`.
This feels as if it makes the code a bit more consistent i.e. all formatting is
either in `SmartAnswer::I18nRenderer#value_for_interpolation` or in methods on
`SmartAnswer::FormattingHelper`.
@floehopper floehopper force-pushed the reduce-dependencies-on-i18n-renderer branch from 6ea3bf3 to 1395259 Compare November 13, 2015 10:59
@floehopper
Copy link
Contributor Author

I've addressed @chrisroos' suggestions, rebased against master and force-pushed in preparation for merging.

floehopper added a commit that referenced this pull request Nov 13, 2015
…nderer

Reduce dependencies on I18nRenderer
@floehopper floehopper merged commit 70f61c3 into master Nov 13, 2015
@floehopper floehopper deleted the reduce-dependencies-on-i18n-renderer branch November 13, 2015 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants