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/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
].freeze
FEED_METHODS =

These optional methods must be implemented in order to gather statistics about each provider’s memory consumption and state.

%i[
  total_memory_bytes
  total_users
].freeze
REQUIRED_METHODS =
(ACTIVITY_METHODS + FEED_METHODS).freeze
RUBY_MAJOR_VERSION =
RUBY_VERSION.split('.')[0..1].join.to_i

Class Method Summary collapse

Class Method Details

.define_provider_methods(klass, prefix = nil, &block) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
# File 'lib/simplefeed/providers.rb', line 41

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_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



14
15
16
# File 'lib/simplefeed/providers.rb', line 14

def self.register(provider_name, provider_class)
  registry[provider_name] = provider_class
end

.registryObject



10
11
12
# File 'lib/simplefeed/providers.rb', line 10

def self.registry
  @registry
end