Class: SwitchPoint::Config

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

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



3
4
5
# File 'lib/switch_point/config.rb', line 3

def initialize
  self.auto_writable = false
end

Instance Method Details

#auto_writable=(val) ⇒ Object



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

def auto_writable=(val)
  @auto_writable = val
end

#auto_writable?Boolean

Returns:

  • (Boolean)


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

def auto_writable?
  @auto_writable
end

#database_name(name, mode) ⇒ Object



24
25
26
# File 'lib/switch_point/config.rb', line 24

def database_name(name, mode)
  switch_points[name][mode]
end

#define_switch_point(name, config) ⇒ Object



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

def define_switch_point(name, config)
  assert_valid_config!(config)
  switch_points[name] = config
end

#fetch(name) ⇒ Object



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

def fetch(name)
  switch_points.fetch(name)
end

#keysObject



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

def keys
  switch_points.keys
end

#model_name(name, mode) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/switch_point/config.rb', line 28

def model_name(name, mode)
  if switch_points[name][mode]
    "#{name}_#{mode}".camelize
  else
    nil
  end
end

#switch_pointsObject



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

def switch_points
  @switch_points ||= {}
end