Sha256: 30aeb353ce277ef810baa79dc706c570e8bd641e4c935ff24ff21fc99f474340

Contents?: true

Size: 883 Bytes

Versions: 14

Compression:

Stored size: 883 Bytes

Contents

module ResqueBus
  class SubscriptionList

    class << self
      def from_redis(redis_hash)
        out = SubscriptionList.new
        
        redis_hash.each do |key, value|
          sub = Subscription.from_redis(value)
          out.add(sub) if sub
        end

        out
      end
    end

    def to_redis
      out = {}
      @subscriptions.values.each do |sub|
        out[sub.key] = sub.to_redis
      end
      out
    end
    
    def initialize
      @subscriptions = {}
    end
    
    def add(sub)
      @subscriptions[sub.key] = sub
    end
    
    def size
      @subscriptions.size
    end
    
    def key(key)
      @subscriptions[key.to_s]
    end
    
    def all
      @subscriptions.values
    end
    
    def matches(attributes)
      out = []
      all.each do |sub|
        out << sub if sub.matches?(attributes)
      end
      out
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
resque-bus-0.3.7 lib/resque_bus/subscription_list.rb
resque-bus-0.3.6 lib/resque_bus/subscription_list.rb
resque-bus-0.3.5 lib/resque_bus/subscription_list.rb
resque-bus-0.3.4 lib/resque_bus/subscription_list.rb
resque-bus-0.3.3 lib/resque_bus/subscription_list.rb
resque-bus-0.3.2 lib/resque_bus/subscription_list.rb
resque-bus-0.3.1 lib/resque_bus/subscription_list.rb
resque-bus-0.3.0 lib/resque_bus/subscription_list.rb
resque-bus-0.2.10 lib/resque_bus/subscription_list.rb
resque-bus-0.2.9 lib/resque_bus/subscription_list.rb
resque-bus-0.2.8 lib/resque_bus/subscription_list.rb
resque-bus-0.2.7 lib/resque_bus/subscription_list.rb
resque-bus-0.2.6 lib/resque_bus/subscription_list.rb
resque-bus-0.2.5 lib/resque_bus/subscription_list.rb