Module: Viewaide::Helpers::MessageHelper
- Included in:
- Viewaide::Helpers
- Defined in:
- lib/viewaide/helpers/message_helper.rb
Instance Method Summary collapse
-
#messages(messages, options = {}) ⇒ String
Generates paragraphs, each containing the values of the hash passed.
Instance Method Details
#messages(messages, options = {}) ⇒ String
Generates paragraphs, each containing the values of the hash passed
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/viewaide/helpers/message_helper.rb', line 17 def (, = {}) except_keys = [[:except]].flatten.compact only_keys = [[:only]].flatten.compact all_keys = .keys if except_keys.any? && only_keys.any? raise ArgumentError, ":only and :except options conflict; use one" end keys = if except_keys.any? all_keys - except_keys elsif only_keys.any? all_keys & only_keys else all_keys end keys.map do |key| if [key].present? content_tag :p, [key], :class => [key, "single-line"].join(" ") end end.join end |