Sha256: d921b8c0820be80d48ea31858d283e02118fcae814ee3d5581354fd59aa2af73

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 KB

Contents

module StackableFlash
  class Config

    class << self
      attr_accessor :config
    end

    DEFAULTS = {
      # Specify how stacked flashes at the same key (e.g. :notice, :errors) should be returned:
      #
      # Example:
      #   flash[:notice] = 'Message 1'
      #   flash[:notice] << 'Message 2'
      #
      # the flash[:notice] object now looks like when :stack_with_proc => lambda { |arr| arr }:
      #
      #   flash[:notice] # => ['Message 1','Message 2']
      #
      # the flash[:notice] object now looks like when :stack_with_proc => lambda { |arr| arr.join('<br/>') }:
      #
      #   flash[:notice] # => "Message 1<br/>Message 2"
      #
      # The default leaves the flash as a string of all the flashes joined by br tags,
      #   to preserve compatibility with existing javascript, and/or views
      #   that expect the flashes as a single string.
      :stack_with_proc => Proc.new { |arr| arr.join('<br/>') }
    }

    #cattr_reader :config
    #cattr_writer :config

    @config ||= DEFAULTS
    def self.configure &block
      yield @config
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
stackable_flash-0.1.1 lib/stackable_flash/config.rb
stackable_flash-0.0.7 lib/stackable_flash/config.rb