Module: SimpleFeed::Providers
- Defined in:
- lib/simplefeed/providers.rb,
lib/simplefeed/providers/key.rb,
lib/simplefeed/providers/hash.rb,
lib/simplefeed/providers/proxy.rb,
lib/simplefeed/providers/redis.rb,
lib/simplefeed/providers/redis/stats.rb,
lib/simplefeed/providers/redis/driver.rb,
lib/simplefeed/providers/base/provider.rb,
lib/simplefeed/providers/hash/provider.rb,
lib/simplefeed/providers/hash/paginator.rb,
lib/simplefeed/providers/redis/provider.rb
Defined Under Namespace
Modules: Base, Hash, Redis Classes: Key, NotImplementedError, Proxy
Constant Summary collapse
- ACTIVITY_METHODS =
These methods must be implemented by each Provider, and operation on a given set of users passed via the user_ids: parameter.
%i(store delete delete_if wipe reset_last_read last_read paginate fetch total_count unread_count)
- FEED_METHODS =
These methods must be implemented in order to gather statistics about each provider’s memory consumption and state.
%i(total_memory_bytes total_users)
- REQUIRED_METHODS =
ACTIVITY_METHODS + FEED_METHODS
Class Method Summary collapse
- .define_provider_methods(klass, prefix = nil, &block) ⇒ Object
- .register(provider_name, provider_class) ⇒ Object
- .registry ⇒ Object
Class Method Details
.define_provider_methods(klass, prefix = nil, &block) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/simplefeed/providers.rb', line 26 def self.define_provider_methods(klass, prefix = nil, &block) # Methods on the class instance klass.class_eval do SimpleFeed::Providers::REQUIRED_METHODS.each do |m| method_name = prefix ? "#{prefix}_#{m.to_s}".to_sym : m define_method(method_name) do |*args, **opts, &b| block.call(self, m, *args, **opts, &b) end end end end |
.register(provider_name, provider_class) ⇒ Object
12 13 14 |
# File 'lib/simplefeed/providers.rb', line 12 def self.register(provider_name, provider_class) self.registry[provider_name] = provider_class end |
.registry ⇒ Object
8 9 10 |
# File 'lib/simplefeed/providers.rb', line 8 def self.registry @registry end |