Class: Saviour::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/saviour/config.rb

Defined Under Namespace

Classes: NotImplemented

Class Method Summary collapse

Class Method Details

.concurrent_workersObject



43
44
45
# File 'lib/saviour/config.rb', line 43

def concurrent_workers
  @concurrent_workers || 4
end

.concurrent_workers=(x) ⇒ Object



47
48
49
# File 'lib/saviour/config.rb', line 47

def concurrent_workers=(x)
  @concurrent_workers = x
end

.processing_enabledObject



14
15
16
17
# File 'lib/saviour/config.rb', line 14

def processing_enabled
  Thread.current.thread_variable_set("Saviour::Config", {}) unless Thread.current.thread_variable_get("Saviour::Config")
  Thread.current.thread_variable_get("Saviour::Config")[:processing_enabled] || true
end

.processing_enabled=(value) ⇒ Object



19
20
21
22
# File 'lib/saviour/config.rb', line 19

def processing_enabled=(value)
  Thread.current.thread_variable_set("Saviour::Config", {}) unless Thread.current.thread_variable_get("Saviour::Config")
  Thread.current.thread_variable_get("Saviour::Config")[:processing_enabled] = value
end

.storageObject



24
25
26
27
28
29
# File 'lib/saviour/config.rb', line 24

def storage
  @semaphore.synchronize do
    Thread.current.thread_variable_set("Saviour::Config", {}) unless Thread.current.thread_variable_get("Saviour::Config")
    Thread.current.thread_variable_get("Saviour::Config")[:storage] || (Thread.main.thread_variable_get("Saviour::Config") && Thread.main.thread_variable_get("Saviour::Config")[:storage]) || NotImplemented.new
  end
end

.storage=(value) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/saviour/config.rb', line 31

def storage=(value)
  @semaphore.synchronize do
    Thread.current.thread_variable_set("Saviour::Config", {}) unless Thread.current.thread_variable_get("Saviour::Config")
    Thread.current.thread_variable_get("Saviour::Config")[:storage] = value

    if Thread.main.thread_variable_get("Saviour::Config").nil?
      Thread.main.thread_variable_set("Saviour::Config", {})
      Thread.main.thread_variable_get("Saviour::Config")[:storage] = value
    end
  end
end