Class: SimpleFeed::Feed
- Inherits:
-
Object
- Object
- SimpleFeed::Feed
- Defined in:
- lib/simplefeed/feed.rb
Instance Attribute Summary collapse
-
#batch_size ⇒ Object
Returns the value of attribute batch_size.
-
#data_key_transformer ⇒ Object
Returns the value of attribute data_key_transformer.
-
#max_size ⇒ Object
Returns the value of attribute max_size.
-
#meta_key_transformer ⇒ Object
Returns the value of attribute meta_key_transformer.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#namespace ⇒ Object
Returns the value of attribute namespace.
-
#per_page ⇒ Object
Returns the value of attribute per_page.
Instance Method Summary collapse
-
#activity(one_or_more_users) ⇒ Object
Depending on the argument returns either
SingleUserActivity
orMultiUserActivity
. - #class_attrs ⇒ Object
- #configure(hash = {}) {|_self| ... } ⇒ Object
- #eql?(other) ⇒ Boolean
-
#initialize(name) ⇒ Feed
constructor
A new instance of Feed.
- #key(user_id) ⇒ Object
- #provider ⇒ Object
- #provider=(definition) ⇒ Object
- #provider_type ⇒ Object
- #user_activity(user_id) ⇒ Object
- #users_activity(user_ids) ⇒ Object
Constructor Details
#initialize(name) ⇒ Feed
Returns a new instance of Feed.
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/simplefeed/feed.rb', line 22 def initialize(name) @name = name @name = name.underscore.to_sym unless name.is_a?(Symbol) # set the defaults if not passed in @meta = {} @namespace = nil @per_page ||= 50 @max_size ||= 1000 @batch_size ||= 10 @meta_key_transformer = nil @data_key_transformer = nil @proxy = nil end |
Instance Attribute Details
#batch_size ⇒ Object
Returns the value of attribute batch_size.
9 10 11 |
# File 'lib/simplefeed/feed.rb', line 9 def batch_size @batch_size end |
#data_key_transformer ⇒ Object
Returns the value of attribute data_key_transformer.
9 10 11 |
# File 'lib/simplefeed/feed.rb', line 9 def data_key_transformer @data_key_transformer end |
#max_size ⇒ Object
Returns the value of attribute max_size.
9 10 11 |
# File 'lib/simplefeed/feed.rb', line 9 def max_size @max_size end |
#meta_key_transformer ⇒ Object
Returns the value of attribute meta_key_transformer.
9 10 11 |
# File 'lib/simplefeed/feed.rb', line 9 def @meta_key_transformer end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
16 17 18 |
# File 'lib/simplefeed/feed.rb', line 16 def name @name end |
#namespace ⇒ Object
Returns the value of attribute namespace.
9 10 11 |
# File 'lib/simplefeed/feed.rb', line 9 def namespace @namespace end |
#per_page ⇒ Object
Returns the value of attribute per_page.
9 10 11 |
# File 'lib/simplefeed/feed.rb', line 9 def per_page @per_page end |
Instance Method Details
#activity(one_or_more_users) ⇒ Object
Depending on the argument returns either SingleUserActivity
or MultiUserActivity
59 60 61 62 63 |
# File 'lib/simplefeed/feed.rb', line 59 def activity(one_or_more_users) one_or_more_users.is_a?(Array) ? users_activity(one_or_more_users) : user_activity(one_or_more_users) end |
#class_attrs ⇒ Object
86 87 88 |
# File 'lib/simplefeed/feed.rb', line 86 def class_attrs SimpleFeed.class_attributes(self.class) end |
#configure(hash = {}) {|_self| ... } ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/simplefeed/feed.rb', line 65 def configure(hash = {}) SimpleFeed.symbolize!(hash) class_attrs.each do |attr| send("#{attr}=", hash[attr]) if hash.key?(attr) end yield self if block_given? end |
#eql?(other) ⇒ Boolean
80 81 82 83 84 |
# File 'lib/simplefeed/feed.rb', line 80 def eql?(other) other.class == self.class && %i(per_page max_size name namespace data_key_transformer meta_key_transformer).all? { |m| send(m).equal?(other.send(m)) } && provider.provider.class == other.provider.provider.class end |
#key(user_id) ⇒ Object
73 74 75 76 77 78 |
# File 'lib/simplefeed/feed.rb', line 73 def key(user_id) SimpleFeed::Providers::Key.new(user_id, namespace: namespace, data_key_transformer: data_key_transformer, meta_key_transformer: ) end |
#provider ⇒ Object
42 43 44 |
# File 'lib/simplefeed/feed.rb', line 42 def provider @proxy end |
#provider=(definition) ⇒ Object
36 37 38 39 40 |
# File 'lib/simplefeed/feed.rb', line 36 def provider=(definition) @proxy = Providers::Proxy.from(definition) @proxy.feed = self @proxy end |
#provider_type ⇒ Object
46 47 48 |
# File 'lib/simplefeed/feed.rb', line 46 def provider_type SimpleFeed::Providers::Base::Provider.class_to_registry(@proxy.provider.class) end |
#user_activity(user_id) ⇒ Object
50 51 52 |
# File 'lib/simplefeed/feed.rb', line 50 def user_activity(user_id) Activity::SingleUser.new(user_id: user_id, feed: self) end |