Class: SwitchPoint::Config

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



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

def initialize
  self.auto_writable = false
end

Instance Attribute Details

#auto_writableObject Also known as: auto_writable?

Returns the value of attribute auto_writable.



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

def auto_writable
  @auto_writable
end

Instance Method Details

#database_name(name, mode) ⇒ Object



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

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

#define_switch_point(name, config) ⇒ Object



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

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

#fetch(name) ⇒ Object



29
30
31
# File 'lib/switch_point/config.rb', line 29

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

#keysObject



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

def keys
  switch_points.keys
end

#model_name(name, mode) ⇒ Object



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

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

#switch_pointsObject



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

def switch_points
  @switch_points ||= {}
end