class SimpleFeed::Providers::Base::Provider
Attributes
feed[RW]
Public Class Methods
class_to_registry(klass)
click to toggle source
# File lib/simplefeed/providers/base/provider.rb, line 19 def self.class_to_registry(klass) klass.name.split('::').delete_if { |n| %w(SimpleFeed Providers Provider).include?(n) }.compact.last.downcase.to_sym end
inherited(klass)
click to toggle source
# File lib/simplefeed/providers/base/provider.rb, line 23 def self.inherited(klass) SimpleFeed::Providers.register(class_to_registry(klass), klass) end
Protected Instance Methods
batch(user_ids) { |key(user_id)| ... }
click to toggle source
# File lib/simplefeed/providers/base/provider.rb, line 66 def batch(user_ids) to_array(user_ids).each_slice(batch_size) do |batch| batch.each do |user_id| yield(key(user_id)) end end end
batch_size()
click to toggle source
# File lib/simplefeed/providers/base/provider.rb, line 54 def batch_size feed.batch_size end
key(user_id)
click to toggle source
# File lib/simplefeed/providers/base/provider.rb, line 46 def key(user_id) feed.key(user_id) end
reset_last_read_value(user_ids:, at: nil)
click to toggle source
# File lib/simplefeed/providers/base/provider.rb, line 29 def reset_last_read_value(user_ids:, at: nil) at = [Time, DateTime, Date].include?(at.class) ? at : Time.now at = at.to_time if at.respond_to?(:to_time) at = at.to_f if at.respond_to?(:to_f) if respond_to?(:reset_last_read) reset_last_read(user_ids: user_ids, at: at) else raise ArgumentError, "Class #{self.class} does not implement #reset_last_read method" end end
tap(value) { || ... }
click to toggle source
# File lib/simplefeed/providers/base/provider.rb, line 41 def tap(value) yield value end
to_array(user_ids)
click to toggle source
# File lib/simplefeed/providers/base/provider.rb, line 50 def to_array(user_ids) user_ids.is_a?(Array) ? user_ids : [user_ids] end
with_response(response = nil) { |response| ... }
click to toggle source
# File lib/simplefeed/providers/base/provider.rb, line 74 def with_response(response = nil) response ||= SimpleFeed::Response.new yield(response) if respond_to?(:transform_response) response.transform do |user_id, result| # calling into a subclass transform_response(user_id, result) end end response end
with_response_batched(user_ids, external_response = nil) { |key, response| ... }
click to toggle source
# File lib/simplefeed/providers/base/provider.rb, line 58 def with_response_batched(user_ids, external_response = nil) with_response(external_response) do |response| batch(user_ids) do |key| response.for(key.consumer) { yield(key, response) } end end end