Class: Rage::Configuration::Deferred

Inherits:
Object
  • Object
show all
Defined in:
lib/rage/configuration.rb

Defined Under Namespace

Classes: Backpressure

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDeferred

Returns a new instance of Deferred.



389
390
391
# File 'lib/rage/configuration.rb', line 389

def initialize
  @configured = false
end

Instance Attribute Details

#backpressureObject

Returns the value of attribute backpressure.



387
388
389
# File 'lib/rage/configuration.rb', line 387

def backpressure
  @backpressure
end

Instance Method Details

#backendObject



393
394
395
396
397
398
399
400
# File 'lib/rage/configuration.rb', line 393

def backend
  unless @backend_class
    @backend_class = Rage::Deferred::Backends::Disk
    @backend_options = parse_disk_backend_options({})
  end

  @backend_class.new(**@backend_options)
end

#backend=(config) ⇒ Object



402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
# File 'lib/rage/configuration.rb', line 402

def backend=(config)
  @configured = true

  backend_id, opts = if config.is_a?(Array)
    [config[0], config[1]]
  else
    [config, {}]
  end

  @backend_class = case backend_id
  when :disk
    @backend_options = parse_disk_backend_options(opts)
    Rage::Deferred::Backends::Disk
  when nil
    Rage::Deferred::Backends::Nil
  else
    raise ArgumentError, "unsupported backend value; supported keys are `:disk` and `nil`"
  end
end

#configured?Boolean

Returns:

  • (Boolean)


466
467
468
# File 'lib/rage/configuration.rb', line 466

def configured?
  @configured
end

#default_disk_storage_pathObject



454
455
456
# File 'lib/rage/configuration.rb', line 454

def default_disk_storage_path
  Pathname.new("storage")
end

#default_disk_storage_prefixObject



458
459
460
# File 'lib/rage/configuration.rb', line 458

def default_disk_storage_prefix
  "deferred-"
end

#has_default_disk_storage?Boolean

Returns:

  • (Boolean)


462
463
464
# File 'lib/rage/configuration.rb', line 462

def has_default_disk_storage?
  default_disk_storage_path.glob("#{default_disk_storage_prefix}*").any?
end