Class: SimpleSwitch::Switch

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_switch/switch.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSwitch



3
4
5
# File 'lib/simple_switch/switch.rb', line 3

def initialize
  @feature_config = load_config
end

Class Method Details

.instanceObject



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

def self.instance
  return @@instance ||= send(:new)
end

Instance Method Details

#delete(feature) ⇒ Object



27
28
29
30
31
# File 'lib/simple_switch/switch.rb', line 27

def delete(feature)
  @feature_config.delete(feature) if valid_feature_name?(feature)

  save_to_yaml
end

#off?(feature, env = Rails.env) ⇒ Boolean



17
18
19
# File 'lib/simple_switch/switch.rb', line 17

def off?(feature, env=Rails.env)
  !on?(feature, env)
end

#on?(feature, env = Rails.env) ⇒ Boolean



13
14
15
# File 'lib/simple_switch/switch.rb', line 13

def on?(feature, env=Rails.env)
  @feature_config[feature][env] if valid_feature_name_for_env?(feature, env)
end

#update(feature, env, value) ⇒ Object



21
22
23
24
25
# File 'lib/simple_switch/switch.rb', line 21

def update(feature, env, value)
  @feature_config[feature][env] = value if valid_feature_name_for_env?(feature, env)

  save_to_yaml
end