Sha256: 65b76ef0c8041edcb693d1cc81a9b10bb13fae4f41551ee267cf5c0d052f2d77

Contents?: true

Size: 718 Bytes

Versions: 37

Compression:

Stored size: 718 Bytes

Contents

require 'volt/models/persistors/base'

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.
        %x{
          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

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
volt-0.8.14 lib/volt/models/persistors/flash.rb
volt-0.8.13 lib/volt/models/persistors/flash.rb
volt-0.8.11 lib/volt/models/persistors/flash.rb
volt-0.8.10 lib/volt/models/persistors/flash.rb
volt-0.8.9 lib/volt/models/persistors/flash.rb
volt-0.8.8 lib/volt/models/persistors/flash.rb
volt-0.8.7 lib/volt/models/persistors/flash.rb
volt-0.8.6 lib/volt/models/persistors/flash.rb
volt-0.8.5 lib/volt/models/persistors/flash.rb
volt-0.8.4 lib/volt/models/persistors/flash.rb
volt-0.8.3 lib/volt/models/persistors/flash.rb
volt-0.8.2 lib/volt/models/persistors/flash.rb
volt-0.8.1 lib/volt/models/persistors/flash.rb
volt-0.8.0 lib/volt/models/persistors/flash.rb
volt-0.7.23 lib/volt/models/persistors/flash.rb
volt-0.7.22 lib/volt/models/persistors/flash.rb
volt-0.7.21 lib/volt/models/persistors/flash.rb
volt-0.7.20 lib/volt/models/persistors/flash.rb
volt-0.7.19 lib/volt/models/persistors/flash.rb
volt-0.7.18 lib/volt/models/persistors/flash.rb