Class: TestTrack::IdentitySessionLocator

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(identity) ⇒ IdentitySessionLocator

Returns a new instance of IdentitySessionLocator.



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

def initialize(identity)
  @identity = identity
end

Instance Attribute Details

#identityObject (readonly)

Returns the value of attribute identity.



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

def identity
  @identity
end

Instance Method Details

#with_sessionObject

Raises:

  • (ArgumentError)


20
21
22
23
24
25
26
27
28
# File 'app/models/test_track/identity_session_locator.rb', line 20

def with_session
  raise ArgumentError, "must provide block to `with_session`" unless block_given?

  if web_session.present?
    yield web_session
  else
    raise "#with_session called outside of web session"
  end
end

#with_visitor(&block) ⇒ Object

rubocop:disable Metrics/AbcSize

Raises:

  • (ArgumentError)


8
9
10
11
12
13
14
15
16
17
18
# File 'app/models/test_track/identity_session_locator.rb', line 8

def with_visitor(&block) # rubocop:disable Metrics/AbcSize
  raise ArgumentError, "must provide block to `with_visitor`" unless block_given?

  if web_session.present?
    yield web_session.visitor_dsl_for(identity)
  elsif job_session.present?
    yield job_session.visitor_dsl_for(identity)
  else
    TestTrack::OfflineSession.with_visitor_for(identity.test_track_identifier_type, identity.test_track_identifier_value, &block)
  end
end