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

Providing procs to collection helpers #75

Merged
merged 7 commits into from
Dec 10, 2019

Conversation

peteryates
Copy link
Member

This change allows procs to be provided to the #collection_radio_buttons and #collection_check_boxes helpers' :value_method, :text_method and hint_method params. These could be used for simple operations like transforming (eg calling #upcase) on the retrieved string. Alternatively, it could be used in the following manner to allow the labels and hints to be fully localised

->(item) { I18n.t("colours.#{item.name.downcase}") }

Refs #68

CollectionItem will hold functionality that's specific to items
belonging to a collection. Initially, this covers the retrieval of the
value depending on what's passed into the :text_method, :value_method or
:hint_method params.

These arguments now accept and properly deal with procs

Refs #68
Instead of using `#send` inline to retrieve the value from `@item`, make
use of `#retrieve` which works with procs.

Refs #68
The :value_method, :text_method and :hint_method params passed to radio
collections and the :hint_method params passed to checkbox collections
now accept procs which can be used to customise the value retrieved from
the item.

This could be used for simple transformations like upcasing the text or
more-complex operations like localising the value, as per the provided
specs

Refs #68
@peteryates peteryates added the enhancement New feature or request label Dec 7, 2019
@peteryates peteryates added this to the Version 1.1.0 milestone Dec 7, 2019
Copy link
Contributor

@tvararu tvararu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! 👍

@peteryates peteryates merged commit ba5236a into version-1.1.0 Dec 10, 2019
@peteryates peteryates deleted the label-hint-and-legend-procs branch December 10, 2019 08:41
@peteryates peteryates mentioned this pull request Dec 10, 2019
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.

None yet

2 participants