Class: RServiceBus::SubscriptionStorage_File
- Inherits:
-
SubscriptionStorage
- Object
- SubscriptionStorage
- RServiceBus::SubscriptionStorage_File
- Defined in:
- lib/rservicebus/SubscriptionStorage/File.rb
Overview
Implementation of Subscription Storage to Redis
Instance Method Summary collapse
- #add(eventName, queueName) ⇒ Object
- #getAll ⇒ Object
-
#initialize(appName, uri) ⇒ SubscriptionStorage_File
constructor
Constructor.
- #remove(eventName, queueName) ⇒ Object
Constructor Details
#initialize(appName, uri) ⇒ SubscriptionStorage_File
Constructor
12 13 14 |
# File 'lib/rservicebus/SubscriptionStorage/File.rb', line 12 def initialize( appName, uri ) super(appName, uri) end |
Instance Method Details
#add(eventName, queueName) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/rservicebus/SubscriptionStorage/File.rb', line 23 def add( eventName, queueName ) if File.exists?( @uri.path ) then subscriptions = YAML::load( File.open( @uri.path ) ) else subscriptions = Hash.new end subscriptions[eventName] = Array.new if subscriptions[eventName].nil? subscriptions[eventName] << queueName subscriptions[eventName] = subscriptions[eventName].uniq File.open( @uri.path, 'w') { |f| f.write( YAML::dump(subscriptions ) ) } return subscriptions end |
#getAll ⇒ Object
16 17 18 19 20 21 |
# File 'lib/rservicebus/SubscriptionStorage/File.rb', line 16 def getAll RServiceBus.log 'Load subscriptions' return Hash.new unless File.exists?( @uri.path ) return YAML::load( File.open( @uri.path ) ) end |
#remove(eventName, queueName) ⇒ Object
40 41 42 |
# File 'lib/rservicebus/SubscriptionStorage/File.rb', line 40 def remove( eventName, queueName ) raise 'Method, remove, needs to be implemented for this subscription storage' end |