Class: SwitchPoint::Config
- Inherits:
-
Object
- Object
- SwitchPoint::Config
- Defined in:
- lib/switch_point/config.rb
Instance Attribute Summary collapse
-
#auto_writable ⇒ Object
(also: #auto_writable?)
Returns the value of attribute auto_writable.
Instance Method Summary collapse
- #database_name(name, mode) ⇒ Object
- #define_switch_point(name, config) ⇒ Object
- #fetch(name) ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #keys ⇒ Object
- #model_name(name, mode) ⇒ Object
- #switch_points ⇒ Object
Constructor Details
#initialize ⇒ Config
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_writable ⇒ Object 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 |
#keys ⇒ Object
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_points ⇒ Object
15 16 17 |
# File 'lib/switch_point/config.rb', line 15 def switch_points @switch_points ||= {} end |