Sha256: 4c8961e3aa2bb5b4077a60cd7af30505c290415b6a7027eac375b7cfc3c6ee5d
Contents?: true
Size: 1004 Bytes
Versions: 1
Compression:
Stored size: 1004 Bytes
Contents
module StackableFlash class FlashStack < Array # TODO: Add smart filters for flashes, like 'sticky' via method_missing. # Handle the following use case: # flash[:notice] = 'First Part' # flash[:notice] += ' Second Part' # => ['First Part Second Part'] 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 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 end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
stackable_flash-0.1.1 | lib/stackable_flash/flash_stack.rb |