Module: Togglify

Defined in:
lib/togglify.rb,
lib/togglify/railtie.rb,
lib/togglify/storage.rb

Defined Under Namespace

Classes: Railtie, Storage

Constant Summary collapse

@@file_path =
nil

Class Method Summary collapse

Class Method Details

.disable(toggle) ⇒ Object



42
43
44
# File 'lib/togglify.rb', line 42

def disable(toggle)
  storage.write_off toggle
end

.disabled?(toggle) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
30
31
32
# File 'lib/togglify.rb', line 27

def disabled?(toggle)
  stored_toggle = storage.read(toggle)
  return false if stored_toggle.nil?
  return false if stored_toggle[storage.env] == :enabled
  true
end

.enable(toggle) ⇒ Object



38
39
40
# File 'lib/togglify.rb', line 38

def enable(toggle)
  storage.write_on toggle
end

.enabled?(toggle) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
22
23
24
25
# File 'lib/togglify.rb', line 19

def enabled?(toggle)
  stored_toggle = storage.read(toggle)
  return true if stored_toggle.nil?
  return true if stored_toggle[storage.env] == :enabled

  false
end

.file_pathObject



11
12
13
# File 'lib/togglify.rb', line 11

def file_path
  @@file_path || Rails.root + ".togglify"
end

.file_path=(file_path) ⇒ Object



15
16
17
# File 'lib/togglify.rb', line 15

def file_path=(file_path)
  @@file_path = file_path
end

.status(toggle) ⇒ Object



34
35
36
# File 'lib/togglify.rb', line 34

def status(toggle)
  storage.read(toggle)
end