Sha256: fd50b17809958d69bba53c8dd44b75abb64365a3827741744847e2ee1d3f4c26

Contents?: true

Size: 739 Bytes

Versions: 20

Compression:

Stored size: 739 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

20 entries across 20 versions & 1 rubygems

Version Path
volt-0.6.5 lib/volt/models/persistors/flash.rb
volt-0.6.4 lib/volt/models/persistors/flash.rb
volt-0.6.3 lib/volt/models/persistors/flash.rb
volt-0.6.2 lib/volt/models/persistors/flash.rb
volt-0.6.1 lib/volt/models/persistors/flash.rb
volt-0.6.0 lib/volt/models/persistors/flash.rb
volt-0.5.18 lib/volt/models/persistors/flash.rb
volt-0.5.17 lib/volt/models/persistors/flash.rb
volt-0.5.16 lib/volt/models/persistors/flash.rb
volt-0.5.15 lib/volt/models/persistors/flash.rb
volt-0.5.14 lib/volt/models/persistors/flash.rb
volt-0.5.13 lib/volt/models/persistors/flash.rb
volt-0.5.12 lib/volt/models/persistors/flash.rb
volt-0.5.11 lib/volt/models/persistors/flash.rb
volt-0.5.10 lib/volt/models/persistors/flash.rb
volt-0.5.9 lib/volt/models/persistors/flash.rb
volt-0.5.8 lib/volt/models/persistors/flash.rb
volt-0.5.7 lib/volt/models/persistors/flash.rb
volt-0.5.6 lib/volt/models/persistors/flash.rb
volt-0.5.4 lib/volt/models/persistors/flash.rb