Skip to content
Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
36 lines (30 sloc) 742 Bytes
module Flipper
module Gates
class PercentageOfTime < Gate
# Internal: The name of the gate. Used for instrumentation, etc.
def name
:percentage_of_time
end
# Internal: Name converted to value safe for adapter.
def key
:percentage_of_time
end
def data_type
:integer
end
def enabled?(value)
value > 0
end
# Internal: Checks if the gate is open for a thing.
#
# Returns true if gate open for thing, false if not.
def open?(context)
value = context.values[key]
rand < (value / 100.0)
end
def protects?(thing)
thing.is_a?(Flipper::Types::PercentageOfTime)
end
end
end
end
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.