Module: StackableFlash
- Defined in:
- lib/stackable_flash.rb,
lib/stackable_flash/config.rb,
lib/stackable_flash/version.rb,
lib/stackable_flash/flash_stack.rb,
lib/stackable_flash/stack_layer.rb
Defined Under Namespace
Modules: StackLayer Classes: Config, FlashStack
Constant Summary collapse
- VERSION =
"0.0.2"
Class Attribute Summary collapse
-
.stacking ⇒ Object
Returns the value of attribute stacking.
Class Method Summary collapse
- .flashing(options, &block) ⇒ Object
-
.not_stacked(&block) ⇒ Object
Regardless of the value of StackableFlash.stacking you can do a local override to force non-stacking.
-
.stacked(config_options = {}, &block) ⇒ Object
Regardless of the value of StackableFlash.stacking you can do a local override to force stacking.
Class Attribute Details
.stacking ⇒ Object
Returns the value of attribute stacking.
8 9 10 |
# File 'lib/stackable_flash.rb', line 8 def stacking @stacking end |
Class Method Details
.flashing(options, &block) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/stackable_flash.rb', line 44 def self.flashing(, &block) return false unless block_given? original = StackableFlash.stacking StackableFlash.stacking = [:forcing] yield StackableFlash.stacking = original end |
.not_stacked(&block) ⇒ Object
Regardless of the value of StackableFlash.stacking you can do a local override to force non-stacking.
StackableFlash.not_stacked do
flash[:notice] = 'a simple string' # Use flash as if this gem did not exist
flash[:notice] = '' # will overwrite the string above
flash[:notice] # => ''
end
38 39 40 41 42 |
# File 'lib/stackable_flash.rb', line 38 def self.not_stacked &block flashing({:forcing => false}) do yield end end |
.stacked(config_options = {}, &block) ⇒ Object
Regardless of the value of StackableFlash.stacking you can do a local override to force stacking.
StackableFlash.stacked do
flash[:notice] = 'a simple string' # Use flash as if this gem did not exist
flash[:notice] = 'another' # will stack the strings
flash[:notice] # => ['a simple string','another'],
# but returned as "a simple string<br/>another" with default config
end
21 22 23 24 25 26 27 28 |
# File 'lib/stackable_flash.rb', line 21 def self.stacked( = {}, &block) flashing({:forcing => true}) do original = StackableFlash::Config.config.dup StackableFlash::Config.config.merge!() yield StackableFlash::Config.config = original end end |