Class: StackableFlash::FlashStack
- Inherits:
-
Array
- Object
- Array
- StackableFlash::FlashStack
- Defined in:
- lib/stackable_flash/flash_stack.rb
Instance Method Summary collapse
Instance Method Details
#+(to_add) ⇒ Object
Handle the following use case:
flash[:notice] = 'First Part'
flash[:notice] += ' Second Part'
> [‘First Part Second Part’]
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/stackable_flash/flash_stack.rb', line 11 def +(to_add) if StackableFlash.stacking if to_add.kind_of?(Array) super(to_add) else # Make sure it responds to +, otherwise just push it onto the stack if self.last.respond_to?(:+) self[self.length - 1] = self.last + to_add else self << to_add end end else super(to_add) end end |
#stack ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/stackable_flash/flash_stack.rb', line 31 def stack if StackableFlash.stacking # Format the stacked flashes according to stack_with_proc lambda StackableFlash::Config.config[:stack_with_proc].call(self) else # All StackableFlash functionality is completely bypassed self end end |