Sha256: eb6e3ba71b2239572c088d8afe3bc38ac0cf07381eeac6e19900a468f01fe785

Contents?: true

Size: 818 Bytes

Versions: 8

Compression:

Stored size: 818 Bytes

Contents

module LiveQA
  ##
  # == LiveQA \Store
  #
  # Store environment data
  #
  class Store
    class << self

      def store
        Thread.current[:request_store] ||= {}
      end

      def clear!
        Thread.current[:request_store] = {}
      end

      def load_from_hash(object = {})
        clear!
        bulk_set(Util.deep_symbolize_key(object)) if object.is_a?(Hash)
      end

      def get(key)
        store[key]
      end
      alias [] get

      def set(key, value)
        store[key] = value
      end
      alias []= set

      def bulk_set(attributes = {})
        attributes.each do |(key, value)|
          set(key, value)
        end
      end

      def exist?(key)
        store.key?(key)
      end

      def delete(key, &block)
        store.delete(key, &block)
      end

    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
liveqa-1.9.6 lib/liveqa/store.rb
liveqa-1.9.5 lib/liveqa/store.rb
liveqa-1.9.4 lib/liveqa/store.rb
liveqa-1.9.3 lib/liveqa/store.rb
liveqa-1.9.2 lib/liveqa/store.rb
liveqa-1.9.1 lib/liveqa/store.rb
liveqa-1.9.0 lib/liveqa/store.rb
liveqa-1.8.3 lib/liveqa/store.rb