1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
require 'socket'
module Unleash
module Strategy
class ApplicationHostname < Base
attr_accessor :hostname
PARAM = 'hostnames'.freeze
def initialize
self.hostname = Socket.gethostname || 'undefined'
end
def name
'applicationHostname'
end
# need: :params['hostnames']
def is_enabled?(params = {}, _context = nil)
return false unless params.is_a?(Hash) && params.has_key?(PARAM)
params[PARAM].split(",").map(&:strip).map(&:downcase).include?(self.hostname)
end
end
end
end
|