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.
-
#max_size ⇒ Object
Returns the value of attribute max_size.
-
#meta ⇒ Object
Returns the value of attribute meta.
-
#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
-
#for(*args) ⇒ Object
deprecated
Deprecated.
Please use #activity instead
-
#initialize(name) ⇒ Feed
constructor
A new instance of Feed.
- #key(user_id) ⇒ Object
- #key_template ⇒ 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.
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/simplefeed/feed.rb', line 15 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 @proxy = nil end |
Instance Attribute Details
#batch_size ⇒ Object
Returns the value of attribute batch_size.
8 9 10 |
# File 'lib/simplefeed/feed.rb', line 8 def batch_size @batch_size end |
#max_size ⇒ Object
Returns the value of attribute max_size.
8 9 10 |
# File 'lib/simplefeed/feed.rb', line 8 def max_size @max_size end |
#meta ⇒ Object
Returns the value of attribute meta.
8 9 10 |
# File 'lib/simplefeed/feed.rb', line 8 def @meta end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/simplefeed/feed.rb', line 9 def name @name end |
#namespace ⇒ Object
Returns the value of attribute namespace.
8 9 10 |
# File 'lib/simplefeed/feed.rb', line 8 def namespace @namespace end |
#per_page ⇒ Object
Returns the value of attribute per_page.
8 9 10 |
# File 'lib/simplefeed/feed.rb', line 8 def per_page @per_page end |
Instance Method Details
#activity(one_or_more_users) ⇒ Object
Depending on the argument returns either SingleUserActivity
or MultiUserActivity
58 59 60 61 62 |
# File 'lib/simplefeed/feed.rb', line 58 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
84 85 86 |
# File 'lib/simplefeed/feed.rb', line 84 def class_attrs SimpleFeed.class_attributes(self.class) end |
#configure(hash = {}) {|_self| ... } ⇒ Object
70 71 72 73 74 75 76 |
# File 'lib/simplefeed/feed.rb', line 70 def configure(hash = {}) SimpleFeed.symbolize!(hash) class_attrs.each do |attr| self.send("#{attr}=", hash[attr]) if hash.key?(attr) end yield self if block_given? end |
#eql?(other) ⇒ Boolean
78 79 80 81 82 |
# File 'lib/simplefeed/feed.rb', line 78 def eql?(other) other.class == self.class && %i(per_page max_size name).all? { |m| self.send(m).equal?(other.send(m)) } && self.provider.provider.class == other.provider.provider.class end |
#for(*args) ⇒ Object
Deprecated.
Please use #activity instead
65 66 67 68 |
# File 'lib/simplefeed/feed.rb', line 65 def for(*args) STDERR.puts 'WARNING: method #for is deprecated, please use #activity' activity(*args) end |
#key(user_id) ⇒ Object
41 42 43 |
# File 'lib/simplefeed/feed.rb', line 41 def key(user_id) SimpleFeed::Providers::Key.new(user_id, key_template) end |
#key_template ⇒ Object
27 28 29 |
# File 'lib/simplefeed/feed.rb', line 27 def key_template SimpleFeed::Key::Template.new(namespace) end |
#provider ⇒ Object
37 38 39 |
# File 'lib/simplefeed/feed.rb', line 37 def provider @proxy end |
#provider=(definition) ⇒ Object
31 32 33 34 35 |
# File 'lib/simplefeed/feed.rb', line 31 def provider=(definition) @proxy = Providers::Proxy.from(definition) @proxy.feed = self @proxy end |
#provider_type ⇒ Object
45 46 47 |
# File 'lib/simplefeed/feed.rb', line 45 def provider_type SimpleFeed::Providers::Base::Provider.class_to_registry(@proxy.provider.class) end |
#user_activity(user_id) ⇒ Object
49 50 51 |
# File 'lib/simplefeed/feed.rb', line 49 def user_activity(user_id) Activity::SingleUser.new(user_id: user_id, feed: self) end |
#users_activity(user_ids) ⇒ Object
53 54 55 |
# File 'lib/simplefeed/feed.rb', line 53 def users_activity(user_ids) Activity::MultiUser.new(user_ids: user_ids, feed: self) end |