Class: Chimpy::UserManager

Inherits:
Object
  • Object
show all
Defined in:
lib/chimpy/user_manager.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeUserManager

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_classObject (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_syncObject



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