Class: Unleash::Strategy::ApplicationHostname
- Defined in:
- lib/unleash/strategy/application_hostname.rb
Instance Attribute Summary collapse
-
#hostname ⇒ Object
Returns the value of attribute hostname.
Instance Method Summary collapse
-
#initialize ⇒ ApplicationHostname
constructor
A new instance of ApplicationHostname.
-
#is_enabled?(params = {}, context = nil) ⇒ Boolean
need: :params.
- #name ⇒ Object
Constructor Details
#initialize ⇒ ApplicationHostname
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
#hostname ⇒ Object
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
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 |
#name ⇒ Object
12 13 14 |
# File 'lib/unleash/strategy/application_hostname.rb', line 12 def name 'applicationHostname' end |