Class: ActiveJob::Temporal::ActiveJobHandlerSource

Inherits:
Object
  • Object
show all
Defined in:
lib/activejob/temporal/active_job_handler_source.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(handler, method_name) ⇒ ActiveJobHandlerSource

Returns a new instance of ActiveJobHandlerSource.



18
19
20
21
# File 'lib/activejob/temporal/active_job_handler_source.rb', line 18

def initialize(handler, method_name)
  @handler = handler
  @method_name = method_name
end

Class Method Details

.match?(handler, method_name) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/activejob/temporal/active_job_handler_source.rb', line 6

def self.match?(handler, method_name)
  new(handler, method_name).match?
end

.match_status(handler, method_name) ⇒ Object



10
11
12
# File 'lib/activejob/temporal/active_job_handler_source.rb', line 10

def self.match_status(handler, method_name)
  new(handler, method_name).match_status
end

.supported?(method_name) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/activejob/temporal/active_job_handler_source.rb', line 14

def self.supported?(method_name)
  new(nil, method_name).supported?
end

Instance Method Details

#match?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/activejob/temporal/active_job_handler_source.rb', line 30

def match?
  match_status == :match
end

#match_statusObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/activejob/temporal/active_job_handler_source.rb', line 34

def match_status
  return :unsupported unless handler.respond_to?(:source_location)

  source_file, source_line = handler.source_location
  return :unsupported unless source_file && source_line

  method_file, = active_job_method_source_location
  return :unsupported unless method_file
  return :no_match unless same_file?(source_file, method_file)

  source_name = source_method_name(source_file, source_line)
  return :unsupported unless source_name

  source_name == method_name.to_s ? :match : :no_match
rescue StandardError
  :unsupported
end

#supported?Boolean

Returns:

  • (Boolean)


23
24
25
26
27
28
# File 'lib/activejob/temporal/active_job_handler_source.rb', line 23

def supported?
  method_file, = active_job_method_source_location
  method_file && File.file?(method_file)
rescue StandardError
  false
end