Class: Services::ReverseMatchService

Inherits:
Object
  • Object
show all
Defined in:
app/models/services/reverse_match_service.rb

Instance Method Summary collapse

Constructor Details

#initialize(host, protocol) ⇒ ReverseMatchService

Returns a new instance of ReverseMatchService.

Raises:

  • (ArgumentError)


5
6
7
8
9
10
# File 'app/models/services/reverse_match_service.rb', line 5

def initialize(host, protocol)
  raise ArgumentError if host.blank?
  raise ArgumentError if protocol.blank?
  @host = host
  @protocol = protocol
end

Instance Method Details

#add(job) ⇒ Object



21
22
23
# File 'app/models/services/reverse_match_service.rb', line 21

def add(job)
  Delayed::Job.enqueue(job, queue: 'reverse_matches')
end

#build_job(type, concept, subject, match_class) ⇒ Object

Raises:

  • (ArgumentError)


12
13
14
15
16
17
18
19
# File 'app/models/services/reverse_match_service.rb', line 12

def build_job(type, concept, subject, match_class)
  raise ArgumentError if type.empty? || concept.nil? || subject.blank? || match_class.blank?
  referer = root_url(host: @host, protocol: @protocol)
  object = rdf_url(concept.origin, host: @host, protocol: @protocol)
  match_classes = Iqvoc::Concept.reverse_match_class_names
  match_class = match_classes[match_class]
  ReverseMatchJob.new(type, concept, match_class, subject, object, referer)
end