Module: SelectionHelper
- Defined in:
- lib/coadjutor/selection_helper.rb
Instance Method Summary collapse
- #selected_if_current(path_to_match, current_path = request.fullpath) ⇒ Object
- #selected_if_params_match(params_to_match, options = { default: {} }) ⇒ Object
- #selected_if_url_matches(string_to_match, options = { default: {} }) ⇒ Object
Instance Method Details
#selected_if_current(path_to_match, current_path = request.fullpath) ⇒ Object
2 3 4 |
# File 'lib/coadjutor/selection_helper.rb', line 2 def selected_if_current(path_to_match, current_path = request.fullpath) current_path == path_to_match ? 'selected' : '' end |
#selected_if_params_match(params_to_match, options = { default: {} }) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/coadjutor/selection_helper.rb', line 6 def selected_if_params_match(params_to_match, = { default: {} }) current_params = if request.query_parameters.empty? [:default] else request.query_parameters end current_params == params_to_match ? 'selected' : '' end |
#selected_if_url_matches(string_to_match, options = { default: {} }) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/coadjutor/selection_helper.rb', line 16 def selected_if_url_matches(string_to_match, = { default: {} }) path_with_params = [request.fullpath, request.query_parameters.to_param]. select(&:present?). join '?' content_to_match = if path_with_params == [:default][:if_path_equals] [:default][:then_match] else path_with_params end content_to_match.include?(string_to_match) ? 'selected' : '' end |