Class: Unleash::Strategy::ApplicationHostname
- Defined in:
- lib/unleash/strategy/application_hostname.rb
Constant Summary collapse
- PARAM =
'hostnames'.freeze
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.
10 11 12 |
# File 'lib/unleash/strategy/application_hostname.rb', line 10 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
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 |
#name ⇒ Object
14 15 16 |
# File 'lib/unleash/strategy/application_hostname.rb', line 14 def name 'applicationHostname' end |