Class: SimpleForum::UserActivity::Checker
- Inherits:
-
Object
- Object
- SimpleForum::UserActivity::Checker
- Defined in:
- app/models/simple_forum/user_activity.rb
Instance Attribute Summary collapse
-
#hash ⇒ Object
readonly
Returns the value of attribute hash.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #bang(object) ⇒ Object
-
#initialize(user, hash) ⇒ Checker
constructor
A new instance of Checker.
- #recent_activity?(object) ⇒ Boolean
Constructor Details
#initialize(user, hash) ⇒ Checker
Returns a new instance of Checker.
7 8 9 10 |
# File 'app/models/simple_forum/user_activity.rb', line 7 def initialize(user, hash) @user = user @hash = hash end |
Instance Attribute Details
#hash ⇒ Object (readonly)
Returns the value of attribute hash.
5 6 7 |
# File 'app/models/simple_forum/user_activity.rb', line 5 def hash @hash end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
5 6 7 |
# File 'app/models/simple_forum/user_activity.rb', line 5 def user @user end |
Instance Method Details
#bang(object) ⇒ Object
28 29 30 31 |
# File 'app/models/simple_forum/user_activity.rb', line 28 def bang(object) return unless user UserActivity.bang(object, user) end |
#recent_activity?(object) ⇒ Boolean
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/models/simple_forum/user_activity.rb', line 12 def recent_activity?(object) type = object.class.base_class.name.to_sym hash[type] ||= {} read_at = hash[type][object.id] return unless read_at if object.is_a?(SimpleForum::Forum) recent_post = object.recent_post recent_post && recent_post.created_at > read_at elsif object.is_a?(SimpleForum::Topic) object.last_updated_at && object.last_updated_at > read_at elsif object.respond_to?(:updated_at) object.updated_at > self[object] end end |