Class: Togglify::Storage
- Inherits:
-
Object
- Object
- Togglify::Storage
- Defined in:
- lib/togglify/storage.rb
Instance Attribute Summary collapse
-
#pstore ⇒ Object
Returns the value of attribute pstore.
Instance Method Summary collapse
- #env ⇒ Object
-
#initialize ⇒ Storage
constructor
A new instance of Storage.
- #list ⇒ Object
- #read(toggle) ⇒ Object
- #write_off(toggle) ⇒ Object
- #write_on(toggle) ⇒ Object
Constructor Details
Instance Attribute Details
#pstore ⇒ Object
Returns the value of attribute pstore.
5 6 7 |
# File 'lib/togglify/storage.rb', line 5 def pstore @pstore end |
Instance Method Details
#env ⇒ Object
28 29 30 |
# File 'lib/togglify/storage.rb', line 28 def env Rails.env.to_sym end |
#list ⇒ Object
11 12 13 |
# File 'lib/togglify/storage.rb', line 11 def list @pstore.transaction(true) { @pstore.roots } end |
#read(toggle) ⇒ Object
15 16 17 18 |
# File 'lib/togglify/storage.rb', line 15 def read(toggle) toggle = sanitize(toggle) @pstore.transaction(true) { @pstore[toggle] } end |
#write_off(toggle) ⇒ Object
24 25 26 |
# File 'lib/togglify/storage.rb', line 24 def write_off(toggle) write(toggle, :disabled) end |
#write_on(toggle) ⇒ Object
20 21 22 |
# File 'lib/togglify/storage.rb', line 20 def write_on(toggle) write(toggle, :enabled) end |