Class: Ribbon::Intercom::Service::Channel::Stores::MockStore
- Defined in:
- lib/ribbon/intercom/service/channel/stores/mock_store.rb
Instance Method Summary collapse
- #channels ⇒ Object
- #delete(channel) ⇒ Object
- #lock ⇒ Object
- #lookup_channel(token) ⇒ Object
- #persist(channel) ⇒ Object
- #token_exists?(token) ⇒ Boolean
- #with_lock(channel, &block) ⇒ Object
Methods inherited from Store
Instance Method Details
#channels ⇒ Object
5 6 7 |
# File 'lib/ribbon/intercom/service/channel/stores/mock_store.rb', line 5 def channels @__channels ||= {} end |
#delete(channel) ⇒ Object
26 27 28 29 30 |
# File 'lib/ribbon/intercom/service/channel/stores/mock_store.rb', line 26 def delete(channel) raise Errors::InvalidChannelError, channel.inspect unless channel.is_a?(Channel) channels.delete(channel.token) nil end |
#lock ⇒ Object
9 10 11 |
# File 'lib/ribbon/intercom/service/channel/stores/mock_store.rb', line 9 def lock @__lock ||= Mutex.new end |
#lookup_channel(token) ⇒ Object
17 18 19 |
# File 'lib/ribbon/intercom/service/channel/stores/mock_store.rb', line 17 def lookup_channel(token) channels[token] end |
#persist(channel) ⇒ Object
21 22 23 24 |
# File 'lib/ribbon/intercom/service/channel/stores/mock_store.rb', line 21 def persist(channel) raise Errors::InvalidChannelError, channel.inspect unless channel.is_a?(Channel) channels[channel.token] = channel end |
#token_exists?(token) ⇒ Boolean
13 14 15 |
# File 'lib/ribbon/intercom/service/channel/stores/mock_store.rb', line 13 def token_exists?(token) channels.key?(token) end |
#with_lock(channel, &block) ⇒ Object
32 33 34 35 36 |
# File 'lib/ribbon/intercom/service/channel/stores/mock_store.rb', line 32 def with_lock(channel, &block) # This is a global lock, not a per-channel lock, but this store is only # for testing so let's KISS. lock.synchronize(&block) end |