Class: Togglify::Storage

Inherits:
Object
  • Object
show all
Defined in:
lib/togglify/storage.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeStorage

Returns a new instance of Storage.



7
8
9
# File 'lib/togglify/storage.rb', line 7

def initialize
  @pstore = PStore.new(Togglify.file_path)
end

Instance Attribute Details

#pstoreObject

Returns the value of attribute pstore.



5
6
7
# File 'lib/togglify/storage.rb', line 5

def pstore
  @pstore
end

Instance Method Details

#envObject



28
29
30
# File 'lib/togglify/storage.rb', line 28

def env
  Rails.env.to_sym
end

#listObject



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