Class: Case::Config

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Config

Returns a new instance of Config.



10
11
12
13
14
15
16
17
18
# File 'lib/teuton/case/config.rb', line 10

def initialize(args)
  @ialias = args[:alias] || Project.value[:ialias].clone
  @global = args[:global] || Project.value[:global].clone
  @local = args[:local] || {}
  @running = {}

  # Set defaults values
  @local[:tt_skip] = @local[:tt_skip] || false
end

Instance Attribute Details

#globalObject (readonly)

This class manage configuration for only one case



8
9
10
# File 'lib/teuton/case/config.rb', line 8

def global
  @global
end

#ialiasObject (readonly)

This class manage configuration for only one case



8
9
10
# File 'lib/teuton/case/config.rb', line 8

def ialias
  @ialias
end

#localObject (readonly)

This class manage configuration for only one case



8
9
10
# File 'lib/teuton/case/config.rb', line 8

def local
  @local
end

#runningObject (readonly)

This class manage configuration for only one case



8
9
10
# File 'lib/teuton/case/config.rb', line 8

def running
  @running
end

Instance Method Details

#get(option, level = 0) ⇒ Object

Read param Option from [running, config or global] Hash data



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/teuton/case/config.rb', line 21

def get(option, level = 0)
  return "NODATA" if level > 3

  return @running[option] if @running[option]

  return @local[option] if @local[option]

  return @global[option] if @global[option]

  search_alias option, level + 1
end

#set(key, value) ⇒ Object



33
34
35
# File 'lib/teuton/case/config.rb', line 33

def set(key, value)
  @running[key] = value
end

#unset(key) ⇒ Object



37
38
39
# File 'lib/teuton/case/config.rb', line 37

def unset(key)
  @running.delete(key)
end