Module: FlashMessenger::Helper
- Included in:
- ViewHelper
- Defined in:
- lib/flash-messenger/helper.rb
Instance Method Summary collapse
- #flash_alert(message, options = nil) ⇒ Object
- #flash_error(message, options = nil) ⇒ Object
- #flash_message(message, options = nil) ⇒ Object
- #flash_messenger ⇒ Object
- #flash_model_error(errors, options = nil) ⇒ Object
- #flash_notice(message, options = nil) ⇒ Object
- #push_flash(message, options, method = nil) ⇒ Object
Instance Method Details
#flash_alert(message, options = nil) ⇒ Object
13 14 15 |
# File 'lib/flash-messenger/helper.rb', line 13 def flash_alert(, = nil) push_flash(, , 'alert') end |
#flash_error(message, options = nil) ⇒ Object
17 18 19 |
# File 'lib/flash-messenger/helper.rb', line 17 def flash_error(, = nil) push_flash(, , 'error') end |
#flash_message(message, options = nil) ⇒ Object
5 6 7 |
# File 'lib/flash-messenger/helper.rb', line 5 def (, = nil) push_flash(, ) end |
#flash_messenger ⇒ Object
28 29 30 |
# File 'lib/flash-messenger/helper.rb', line 28 def flash_messenger RequestStore.store[:flash_messenger] ||= [] end |
#flash_model_error(errors, options = nil) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/flash-messenger/helper.rb', line 21 def flash_model_error(errors, = nil) errors = errors.errors if errors.is_a? ActiveRecord::Base errors..to_a.each do || push_flash(, , 'error') end end |
#flash_notice(message, options = nil) ⇒ Object
9 10 11 |
# File 'lib/flash-messenger/helper.rb', line 9 def flash_notice(, = nil) push_flash(, , 'notice') end |
#push_flash(message, options, method = nil) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/flash-messenger/helper.rb', line 32 def push_flash(, , method = nil) = .nil? ? : .clone if method.nil? if .nil? job = [] else job = [, ] end else job = [, , method] end flash_messenger << job end |