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
- #each_key(&block) ⇒ 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.
8 9 10 |
# File 'lib/switch_point/config.rb', line 8 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.
5 6 7 |
# File 'lib/switch_point/config.rb', line 5 def auto_writable @auto_writable end |
Instance Method Details
#database_name(name, mode) ⇒ Object
21 22 23 |
# File 'lib/switch_point/config.rb', line 21 def database_name(name, mode) fetch(name)[mode] end |
#define_switch_point(name, config) ⇒ Object
12 13 14 15 |
# File 'lib/switch_point/config.rb', line 12 def define_switch_point(name, config) assert_valid_config!(config) switch_points[name] = config end |
#each_key(&block) ⇒ Object
39 40 41 |
# File 'lib/switch_point/config.rb', line 39 def each_key(&block) switch_points.each_key(&block) end |
#fetch(name) ⇒ Object
31 32 33 |
# File 'lib/switch_point/config.rb', line 31 def fetch(name) switch_points.fetch(name) end |
#keys ⇒ Object
35 36 37 |
# File 'lib/switch_point/config.rb', line 35 def keys switch_points.keys end |
#model_name(name, mode) ⇒ Object
25 26 27 28 29 |
# File 'lib/switch_point/config.rb', line 25 def model_name(name, mode) if fetch(name)[mode] "#{name}_#{mode}".camelize end end |
#switch_points ⇒ Object
17 18 19 |
# File 'lib/switch_point/config.rb', line 17 def switch_points @switch_points ||= {} end |