Class: Unleash::Strategy::ApplicationHostname

Inherits:
Base
  • Object
show all
Defined in:
lib/unleash/strategy/application_hostname.rb

Constant Summary collapse

PARAM =
'hostnames'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeApplicationHostname

Returns a new instance of ApplicationHostname.



10
11
12
# File 'lib/unleash/strategy/application_hostname.rb', line 10

def initialize
  self.hostname = Socket.gethostname || 'undefined'
end

Instance Attribute Details

#hostnameObject

Returns the value of attribute hostname.



6
7
8
# File 'lib/unleash/strategy/application_hostname.rb', line 6

def hostname
  @hostname
end

Instance Method Details

#is_enabled?(params = {}, _context = nil) ⇒ Boolean

need: :params

Returns:

  • (Boolean)


19
20
21
22
23
# File 'lib/unleash/strategy/application_hostname.rb', line 19

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

#nameObject



14
15
16
# File 'lib/unleash/strategy/application_hostname.rb', line 14

def name
  'applicationHostname'
end