Class: Chimpy::UserManager
- Inherits:
-
Object
- Object
- Chimpy::UserManager
- Defined in:
- lib/chimpy/user_manager.rb
Instance Attribute Summary collapse
-
#sync_class ⇒ Object
readonly
Returns the value of attribute sync_class.
Instance Method Summary collapse
-
#initialize ⇒ UserManager
constructor
A new instance of UserManager.
- #mark_as_synced(emails) ⇒ Object
- #to_sync ⇒ Object
Constructor Details
#initialize ⇒ UserManager
Returns a new instance of UserManager.
5 6 7 |
# File 'lib/chimpy/user_manager.rb', line 5 def initialize @sync_class = Chimpy.configuration.sync_class end |
Instance Attribute Details
#sync_class ⇒ Object (readonly)
Returns the value of attribute sync_class.
3 4 5 |
# File 'lib/chimpy/user_manager.rb', line 3 def sync_class @sync_class end |
Instance Method Details
#mark_as_synced(emails) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/chimpy/user_manager.rb', line 15 def mark_as_synced(emails) emails.each do |email| found = sync_class.find_by_email(email) found.update(chimpy_synced_at: Time.now) if found end end |
#to_sync ⇒ Object
9 10 11 12 13 |
# File 'lib/chimpy/user_manager.rb', line 9 def to_sync never_synced = sync_class.where(chimpy_synced_at: nil) needing_sync = sync_class.where('updated_at > chimpy_synced_at') never_synced + needing_sync end |