lib/totoro/config.rb in totoro-0.1.3 vs lib/totoro/config.rb in totoro-0.1.4
- old
+ new
@@ -1,27 +1,28 @@
+# frozen_string_literal: true
+
module Totoro
class Config
- class <<self
- def data
- @data ||= Rails.application.config_for(:totoro).with_indifferent_access
- end
+ def initialize(prefix)
+ @data = Rails.application.config_for(:totoro).with_indifferent_access
+ @data = @data[prefix] if prefix.present?
+ end
- def reset_data
- @data = nil
- end
+ def reset_data
+ @data = nil
+ end
- def connect
- data[:connect]
- end
+ def connect
+ @data[:connect]
+ end
- def queue(id)
- name = data[:queue][id][:name]
- settings = { durable: data[:queue][id][:durable] }
- [name, settings]
- end
+ def queue(id)
+ name = data[:queue][id][:name]
+ settings = { durable: data[:queue][id][:durable] }
+ [name, settings]
+ end
- def get_worker(worker_class)
- ::Worker.const_get(worker_class.to_s.camelize).new
- end
+ def get_worker(worker_class)
+ ::Worker.const_get(worker_class.to_s.camelize).new
end
end
end