Class: Flamingo::Subscription

Inherits:
Object
  • Object
show all
Defined in:
lib/flamingo/subscription.rb

Overview

Track stream subscriptions in the Redis db.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Subscription

Returns a new instance of Subscription.



21
22
23
# File 'lib/flamingo/subscription.rb', line 21

def initialize(name)
  self.name = name
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



20
21
22
# File 'lib/flamingo/subscription.rb', line 20

def name
  @name
end

Class Method Details

.allObject



7
8
9
10
11
# File 'lib/flamingo/subscription.rb', line 7

def all
  Flamingo.redis.smembers("subscriptions").map do |name|
    new(name)
  end
end

.find(name) ⇒ Object



13
14
15
16
17
# File 'lib/flamingo/subscription.rb', line 13

def find(name)
  if Flamingo.redis.sismember("subscriptions",name)
    Subscription.new(name)
  end
end

Instance Method Details

#deleteObject



30
31
32
33
# File 'lib/flamingo/subscription.rb', line 30

def delete
  Flamingo.logger.info("Removing #{name} from subscriptions")
  Flamingo.redis.srem("subscriptions",name)
end

#saveObject



25
26
27
28
# File 'lib/flamingo/subscription.rb', line 25

def save
  Flamingo.logger.info("Adding #{name} to subscriptions")
  Flamingo.redis.sadd("subscriptions",name)
end