Class: Unleash::Strategy::ApplicationHostname

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeApplicationHostname

Returns a new instance of ApplicationHostname.



8
9
10
# File 'lib/unleash/strategy/application_hostname.rb', line 8

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)


17
18
19
20
21
# File 'lib/unleash/strategy/application_hostname.rb', line 17

def is_enabled?(params = {}, context = nil)
  return false unless params.is_a?(Hash) && params.has_key?('hostnames')

  params['hostnames'].split(",").map(&:strip).map{|h| h.downcase }.include?(self.hostname)
end

#nameObject



12
13
14
# File 'lib/unleash/strategy/application_hostname.rb', line 12

def name
  'applicationHostname'
end