Sha256: 9b0097ddb01cf1e8b5c9fadc04016dde305d18fee3e9a7b3b5f572a6796ec284

Contents?: true

Size: 674 Bytes

Versions: 3

Compression:

Stored size: 674 Bytes

Contents

require 'json'

module Pakyow
  module UI
    # Manages mutations.
    #
    # This is the default registry in production systems and is required in
    # deployments with more than one app instance.
    #
    # @api private
    class RedisMutationRegistry
      include Singleton

      def initialize
      end

      def register(scope, mutation)
        Pakyow::Realtime.redis.sadd(key(scope), mutation.to_json)
      end

      def mutations(scope)
        Pakyow::Realtime.redis.smembers(key(scope)).map do |m|
          Hash.strhash(JSON.parse(m))
        end
      end

      private

      def key(scope)
        "pui-mutation-#{scope}"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pakyow-ui-0.10.2 pakyow-ui/lib/pakyow-ui/registries/redis_mutation_registry.rb
pakyow-ui-0.10.1 pakyow-ui/lib/pakyow-ui/registries/redis_mutation_registry.rb
pakyow-ui-0.10.0 pakyow-ui/lib/pakyow-ui/registries/redis_mutation_registry.rb