Class: Ap4r::AsyncHelper::Converters::ToRailsBase

Inherits:
Base
  • Object
show all
Defined in:
lib/ap4r/async_helper.rb

Direct Known Subclasses

Http, WebService

Instance Method Summary collapse

Methods inherited from Base

dispatch_mode, #make_params, #make_rm_options

Constructor Details

#initialize(url_options, async_params, rm_options, url_for_handler) ⇒ ToRailsBase

Returns a new instance of ToRailsBase.



242
243
244
245
246
247
248
249
# File 'lib/ap4r/async_helper.rb', line 242

def initialize(url_options, async_params, rm_options, url_for_handler)
  super

  @url_options ||= {}
  @url_options[:controller] ||= @url_for_handler.controller_path.gsub("/", ".")
  @url_options[:url] ||= {:controller => url_options[:controller], :action => url_options[:action]}
  @url_options[:url][:controller] ||= url_options[:controller] if url_options[:url].kind_of?(Hash)
end

Instance Method Details

#queue_nameObject



251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
# File 'lib/ap4r/async_helper.rb', line 251

def queue_name
  queue_name = @rm_options[:queue]
  return queue_name if queue_name

  queue_prefix = ::Ap4r::AsyncHelper::Base.default_queue_prefix
  queue_prefix = queue_prefix.chomp(".")
  url = @url_options[:url]
  if url.kind_of?(Hash)
    @rm_options[:queue] ||=
      [queue_prefix, url[:controller].to_s, url[:action].to_s].join(".")
  else
    @rm_options[:queue] ||=
      "#{queue_prefix}.#{URI.parse(url).path.gsub("/", ".")}"
  end
  @rm_options[:queue]
end