Sha256: c2bd70369338baf1cacc0c61ade19954d724ecbdb092f5e481a05838f8ae0f8a

Contents?: true

Size: 862 Bytes

Versions: 22

Compression:

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

        # Need to return nil to prevent non-opal object return
        nil
      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

22 entries across 22 versions & 1 rubygems

Version Path
volt-0.9.3.pre1 lib/volt/models/persistors/flash.rb
volt-0.9.2 lib/volt/models/persistors/flash.rb
volt-0.9.1 lib/volt/models/persistors/flash.rb
volt-0.9.1.pre5 lib/volt/models/persistors/flash.rb
volt-0.9.1.pre4 lib/volt/models/persistors/flash.rb
volt-0.9.1.pre3 lib/volt/models/persistors/flash.rb
volt-0.9.1.pre2 lib/volt/models/persistors/flash.rb
volt-0.9.1.pre1 lib/volt/models/persistors/flash.rb
volt-0.9.0 lib/volt/models/persistors/flash.rb
volt-0.9.0.pre7 lib/volt/models/persistors/flash.rb
volt-0.9.0.pre6 lib/volt/models/persistors/flash.rb
volt-0.9.0.pre5 lib/volt/models/persistors/flash.rb
volt-0.9.0.pre4 lib/volt/models/persistors/flash.rb
volt-0.9.0.pre3 lib/volt/models/persistors/flash.rb
volt-0.9.0.pre2 lib/volt/models/persistors/flash.rb
volt-0.9.0.pre1 lib/volt/models/persistors/flash.rb
volt-0.8.27.beta9 lib/volt/models/persistors/flash.rb
volt-0.8.27.beta8 lib/volt/models/persistors/flash.rb
volt-0.8.27.beta7 lib/volt/models/persistors/flash.rb
volt-0.8.27.beta6 lib/volt/models/persistors/flash.rb