Class: TestTrack::WebSessionVisitorRepository

Inherits:
Object
  • Object
show all
Defined in:
app/models/test_track/web_session_visitor_repository.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(current_identity:, unauthenticated_visitor_id:) ⇒ WebSessionVisitorRepository

Returns a new instance of WebSessionVisitorRepository.



4
5
6
7
# File 'app/models/test_track/web_session_visitor_repository.rb', line 4

def initialize(current_identity:, unauthenticated_visitor_id:)
  @current_identity = current_identity
  @unauthenticated_visitor_id = unauthenticated_visitor_id
end

Instance Attribute Details

#current_identityObject (readonly)

Returns the value of attribute current_identity.



2
3
4
# File 'app/models/test_track/web_session_visitor_repository.rb', line 2

def current_identity
  @current_identity
end

#unauthenticated_visitor_idObject (readonly)

Returns the value of attribute unauthenticated_visitor_id.



2
3
4
# File 'app/models/test_track/web_session_visitor_repository.rb', line 2

def unauthenticated_visitor_id
  @unauthenticated_visitor_id
end

Instance Method Details

#allObject



31
32
33
# File 'app/models/test_track/web_session_visitor_repository.rb', line 31

def all
  identity_visitor_map.values.to_set << current
end

#authenticate!(identity) ⇒ Object



25
26
27
28
29
# File 'app/models/test_track/web_session_visitor_repository.rb', line 25

def authenticate!(identity)
  @current_identity = identity
  identity_visitor_map[identity] = unauthenticated
  unauthenticated.link_identity!(identity)
end

#currentObject



9
10
11
12
13
14
15
# File 'app/models/test_track/web_session_visitor_repository.rb', line 9

def current
  if current_identity
    for_identity(current_identity)
  else
    unauthenticated
  end
end

#for_identity(identity) ⇒ Object



17
18
19
# File 'app/models/test_track/web_session_visitor_repository.rb', line 17

def for_identity(identity)
  identity_visitor_map[identity] ||= TestTrack::LazyVisitorByIdentity.new(identity)
end

#forget_unauthenticated!Object



21
22
23
# File 'app/models/test_track/web_session_visitor_repository.rb', line 21

def forget_unauthenticated!
  @unauthenticated = TestTrack::Visitor.new
end

#notify_unsynced_assignments!Object



35
36
37
38
39
# File 'app/models/test_track/web_session_visitor_repository.rb', line 35

def notify_unsynced_assignments!
  all.each do |visitor|
    TestTrack::ThreadedVisitorNotifier.new(visitor).notify if visitor.loaded? && visitor.unsynced_assignments.present?
  end
end