Class: Togls::Feature

Inherits:
Object
  • Object
show all
Defined in:
lib/togls/feature.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key) ⇒ Feature

Returns a new instance of Feature.



5
6
7
8
# File 'lib/togls/feature.rb', line 5

def initialize(key)
  @key = key
  off
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



3
4
5
# File 'lib/togls/feature.rb', line 3

def key
  @key
end

Instance Method Details

#offObject



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

def off
  @rule = Rule.new { false }
end

#on(rule = nil) ⇒ Object



10
11
12
13
14
15
# File 'lib/togls/feature.rb', line 10

def on(rule = nil)
  if rule.nil?
    rule = Rule.new { true }
  end
  @rule = rule 
end

#on?(target = nil) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/togls/feature.rb', line 21

def on?(target = nil)
  @rule.run(target)
end