Class: SimpleToggle::Toggle

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/simple_toggle.rb

Class Method Summary collapse

Class Method Details

.active?(feature) ⇒ Boolean

Returns:

  • (Boolean)


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

def self.active?(feature)
  toggle = Toggle.where(name: feature, active: true).first
end

.require(feature) ⇒ Object



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

def self.require(feature)
  raise unless Toggle.active?(feature)
end

.when_active(feature) ⇒ Object



9
10
11
# File 'lib/simple_toggle.rb', line 9

def self.when_active(feature)
  yield if Toggle.active?(feature)
end