Module: Sbmt::Strangler::Flipper
- Defined in:
- lib/sbmt/strangler/flipper.rb
Defined Under Namespace
Classes: FLIPPER_ID_STRUCT
Constant Summary
collapse
- ONTIME_ACTOR_REGEXP =
/^ONTIME:(\d{2})-(\d{2})$/
Class Method Summary
collapse
Class Method Details
.enabled?(feature_name, *actors) ⇒ Boolean
12
13
14
15
16
17
|
# File 'lib/sbmt/strangler/flipper.rb', line 12
def enabled?(feature_name, *actors)
raise "feature name is blank" if feature_name.blank?
actors = Array(actors).flatten.compact
::Flipper.enabled?(feature_name, *actors.map { FLIPPER_ID_STRUCT.new(_1) })
end
|
.enabled_on_time?(feature_name) ⇒ Boolean
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/sbmt/strangler/flipper.rb', line 19
def enabled_on_time?(feature_name)
raise "feature name is blank" if feature_name.blank?
hours_ranges =
::Flipper[feature_name]
.actors_value
.filter_map { |e|
e.match(ONTIME_ACTOR_REGEXP) {
$LAST_MATCH_INFO.captures.map(&:to_i)
}
}
.compact
hour_now = DateTime.now.in_time_zone.hour
hours_ranges.any? { |range| (range.first..range.last).cover?(hour_now) }
end
|