Module: Devise::Models::Lastseenable

Defined in:
lib/devise_last_seen/model.rb

Instance Method Summary collapse

Instance Method Details

#last_seen_at_attribute_writerObject



14
15
16
# File 'lib/devise_last_seen/model.rb', line 14

def last_seen_at_attribute_writer
  @last_seen_at_attribute_writer ||= :"#{Devise.last_seen_at_attribute}="
end

#track_last_seen!Object



4
5
6
7
8
9
10
11
12
# File 'lib/devise_last_seen/model.rb', line 4

def track_last_seen!
  return if new_record?
  return unless respond_to?(last_seen_at_attribute_writer)
  return unless public_send(Devise.last_seen_at_attribute).to_i < (Time.now - Devise.last_seen_at_interval).to_i

  public_send(last_seen_at_attribute_writer, DateTime.now)

  save(validate: false)
end