Module: SwitchPoint::ClassMethods

Included in:
SwitchPoint
Defined in:
lib/switch_point.rb

Instance Method Summary collapse

Instance Method Details

#configObject



11
12
13
# File 'lib/switch_point.rb', line 11

def config
  @config ||= Config.new
end

#configure(&block) ⇒ Object



7
8
9
# File 'lib/switch_point.rb', line 7

def configure(&block)
  block.call(config)
end

#readonly!(name) ⇒ Object



21
22
23
# File 'lib/switch_point.rb', line 21

def readonly!(name)
  ProxyRepository.checkout(name).readonly!
end

#readonly_all!Object



15
16
17
18
19
# File 'lib/switch_point.rb', line 15

def readonly_all!
  config.keys.each do |name|
    readonly!(name)
  end
end

#with_mode(mode, *names, &block) ⇒ Object



51
52
53
54
55
56
57
# File 'lib/switch_point.rb', line 51

def with_mode(mode, *names, &block)
  names.reverse.inject(block) do |func, name|
    lambda do
      ProxyRepository.checkout(name).with_mode(mode, &func)
    end
  end.call
end

#with_readonly(*names, &block) ⇒ Object



35
36
37
# File 'lib/switch_point.rb', line 35

def with_readonly(*names, &block)
  with_mode(:readonly, *names, &block)
end

#with_readonly_all(&block) ⇒ Object



39
40
41
# File 'lib/switch_point.rb', line 39

def with_readonly_all(&block)
  with_readonly(*config.keys, &block)
end

#with_writable(*names, &block) ⇒ Object



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

def with_writable(*names, &block)
  with_mode(:writable, *names, &block)
end

#with_writable_all(&block) ⇒ Object



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

def with_writable_all(&block)
  with_writable(*config.keys, &block)
end

#writable!(name) ⇒ Object



31
32
33
# File 'lib/switch_point.rb', line 31

def writable!(name)
  ProxyRepository.checkout(name).writable!
end

#writable_all!Object



25
26
27
28
29
# File 'lib/switch_point.rb', line 25

def writable_all!
  config.keys.each do |name|
    writable!(name)
  end
end