Sha256: bce6a348c37cb89bcaa116db0b6ff9cd51fd36df70a1c0dffa99d2f184efba05

Contents?: true

Size: 800 Bytes

Versions: 33

Compression:

Stored size: 800 Bytes

Contents

require 'volt/models/persistors/base'

module Volt
  module Persistors
    class Flash < Base
      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

33 entries across 33 versions & 1 rubygems

Version Path
volt-0.9.7.pre8 lib/volt/models/persistors/flash.rb
volt-0.9.7.pre7 lib/volt/models/persistors/flash.rb
volt-0.9.7.pre6 lib/volt/models/persistors/flash.rb
volt-0.9.7.pre5 lib/volt/models/persistors/flash.rb
volt-0.9.7.pre3 lib/volt/models/persistors/flash.rb
volt-0.9.7.pre2 lib/volt/models/persistors/flash.rb
volt-0.9.6 lib/volt/models/persistors/flash.rb
volt-0.9.6.pre3 lib/volt/models/persistors/flash.rb
volt-0.9.6.pre2 lib/volt/models/persistors/flash.rb
volt-0.9.6.pre1 lib/volt/models/persistors/flash.rb
volt-0.9.5 lib/volt/models/persistors/flash.rb
volt-0.9.5.pre12 lib/volt/models/persistors/flash.rb
volt-0.9.5.pre11 lib/volt/models/persistors/flash.rb
volt-0.9.5.pre9 lib/volt/models/persistors/flash.rb
volt-0.9.5.pre8 lib/volt/models/persistors/flash.rb
volt-0.9.5.pre7 lib/volt/models/persistors/flash.rb
volt-0.9.5.pre6 lib/volt/models/persistors/flash.rb
volt-0.9.5.pre5 lib/volt/models/persistors/flash.rb
volt-0.9.5.pre4 lib/volt/models/persistors/flash.rb
volt-0.9.5.pre3 lib/volt/models/persistors/flash.rb