class Chimpy::UserManager

Attributes

sync_class[R]

Public Class Methods

new() click to toggle source
# File lib/chimpy/user_manager.rb, line 5
def initialize
  @sync_class = Chimpy.configuration.sync_class
end

Public Instance Methods

mark_as_synced(emails) click to toggle source
# 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() click to toggle source
# 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