Sha256: 0f4e40bdb4a8798011fb225f2d483370eeb5c6d3a58f6f6e4b44b56424596bae

Contents?: true

Size: 786 Bytes

Versions: 16

Compression:

Stored size: 786 Bytes

Contents

require 'volt/models/persistors/base'

module Volt
  module Persistors
    class Flash < Base
      def initialize(model)
        @model = model
      end

      def added(model, index)
        if Volt.client?
          # Setup a new timer for clearing the flash.
          `
            setTimeout(function() {
              self.$clear_model(model);
            }, 5000);
          `
        end
      end

      def clear_model(model)
        @model.delete(model)

        # Clear out the parent collection (usually the main flash)
        # Makes it so flash.empty? reflects if there is any outstanding
        # flashes.
        if @model.size == 0
          collection_name = @model.path[-1]
          @model.parent.delete(collection_name)
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
volt-0.8.27.beta3 lib/volt/models/persistors/flash.rb
volt-0.8.27.beta2 lib/volt/models/persistors/flash.rb
volt-0.8.27.beta1 lib/volt/models/persistors/flash.rb
volt-0.8.26.beta1 lib/volt/models/persistors/flash.rb
volt-0.8.26 lib/volt/models/persistors/flash.rb
volt-0.8.24 lib/volt/models/persistors/flash.rb
volt-0.8.23 lib/volt/models/persistors/flash.rb
volt-0.8.22 lib/volt/models/persistors/flash.rb
volt-0.8.22.beta2 lib/volt/models/persistors/flash.rb
volt-0.8.22.beta1 lib/volt/models/persistors/flash.rb
volt-0.8.21 lib/volt/models/persistors/flash.rb
volt-0.8.20 lib/volt/models/persistors/flash.rb
volt-0.8.19 lib/volt/models/persistors/flash.rb
volt-0.8.18 lib/volt/models/persistors/flash.rb
volt-0.8.17 lib/volt/models/persistors/flash.rb
volt-0.8.16 lib/volt/models/persistors/flash.rb