Class: RailsAsyncMethods::ActiveJobOptionsParser

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_async_methods/active_job_options_parser.rb

Constant Summary collapse

SET_OPTIONS =
%i[queue wait_until wait priority].freeze
STRING_ARG_SEPERATOR =
[':', ','].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ ActiveJobOptionsParser

Returns a new instance of ActiveJobOptionsParser.



8
9
10
11
12
13
14
15
# File 'lib/rails_async_methods/active_job_options_parser.rb', line 8

def initialize(opts={})
  @prefix = method_prefix(opts[:prefix])
  @queue = opts[:queue]
  @wait_until = opts[:wait_until].to_f if opts[:wait_until]
  @wait = opts[:wait].seconds.to_f if opts[:wait]
  @priority = opts[:priority].to_i if opts[:priority]
  @job = get_job_obj(opts[:job])
end

Instance Attribute Details

#jobObject (readonly)

Returns the value of attribute job.



5
6
7
# File 'lib/rails_async_methods/active_job_options_parser.rb', line 5

def job
  @job
end

#prefixObject (readonly)

Returns the value of attribute prefix.



5
6
7
# File 'lib/rails_async_methods/active_job_options_parser.rb', line 5

def prefix
  @prefix
end

#priorityObject (readonly)

Returns the value of attribute priority.



5
6
7
# File 'lib/rails_async_methods/active_job_options_parser.rb', line 5

def priority
  @priority
end

#queueObject (readonly)

Returns the value of attribute queue.



5
6
7
# File 'lib/rails_async_methods/active_job_options_parser.rb', line 5

def queue
  @queue
end

#waitObject (readonly)

Returns the value of attribute wait.



5
6
7
# File 'lib/rails_async_methods/active_job_options_parser.rb', line 5

def wait
  @wait
end

#wait_untilObject (readonly)

Returns the value of attribute wait_until.



5
6
7
# File 'lib/rails_async_methods/active_job_options_parser.rb', line 5

def wait_until
  @wait_until
end

Instance Method Details

#to_hObject



17
18
19
# File 'lib/rails_async_methods/active_job_options_parser.rb', line 17

def to_h
  valid_instance_values
end

#to_sObject



21
22
23
24
25
# File 'lib/rails_async_methods/active_job_options_parser.rb', line 21

def to_s
  return '' if valid_instance_values.empty?

  valid_instance_values.to_s
end