Class: OFFS
- Inherits:
-
Object
show all
- Includes:
- InjectableDependencies
- Defined in:
- lib/offs.rb,
lib/offs/flags.rb,
lib/offs/version.rb,
lib/offs/permutations.rb
Defined Under Namespace
Classes: FeatureDisabled, Flags, Permutations
Constant Summary
collapse
- VERSION =
"1.4.0"
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(flag, options = {}) ⇒ OFFS
Returns a new instance of OFFS.
38
39
40
41
|
# File 'lib/offs.rb', line 38
def initialize(flag, options={})
initialize_dependencies options[:dependencies]
self.flag = flag
end
|
Class Method Details
.feature_flags ⇒ Object
31
32
33
|
# File 'lib/offs.rb', line 31
def feature_flags
Flags.instance.to_a
end
|
.if_you_do_not_want_to(flag, &block) ⇒ Object
21
22
23
24
25
|
# File 'lib/offs.rb', line 21
def if_you_do_not_want_to(flag, &block)
so_you_want_to(flag) do |you|
you.may_still_need_to(&block)
end
end
|
.if_you_would_like_to(flag, &block) ⇒ Object
15
16
17
18
19
|
# File 'lib/offs.rb', line 15
def if_you_would_like_to(flag, &block)
so_you_want_to(flag) do |you|
you.would_like_to(&block)
end
end
|
.raise_error_unless_we(flag) ⇒ Object
27
28
29
|
# File 'lib/offs.rb', line 27
def raise_error_unless_we(flag)
new(flag).raise_error_unless_we
end
|
.so_you_want_to(flag, &block) ⇒ Object
11
12
13
|
# File 'lib/offs.rb', line 11
def so_you_want_to(flag, &block)
new(flag).so_you_want_to(&block)
end
|
Instance Method Details
#may_still_need_to(&block) ⇒ Object
52
53
54
|
# File 'lib/offs.rb', line 52
def may_still_need_to(&block)
when_flag(false, &block)
end
|
#raise_error_unless_we ⇒ Object
56
57
58
59
60
61
62
|
# File 'lib/offs.rb', line 56
def raise_error_unless_we
unless flag_enabled?
raise FeatureDisabled,
"Attempted to access code that is only available when the '#{flag}' " \
+ "feature is enabled, and it is currenlty disabled."
end
end
|
#so_you_want_to(&block) ⇒ Object
43
44
45
46
|
# File 'lib/offs.rb', line 43
def so_you_want_to(&block)
block.call(self)
return result
end
|
#would_like_to(&block) ⇒ Object
48
49
50
|
# File 'lib/offs.rb', line 48
def would_like_to(&block)
when_flag(true, &block)
end
|