Sha256: 239214f2a13cab84ecb5867df75ce7f0e28e528a30f59f0ef9abf1acab862ee4

Contents?: true

Size: 555 Bytes

Versions: 1

Compression:

Stored size: 555 Bytes

Contents

require 'socket'

module Unleash
  module Strategy
    class ApplicationHostname < Base
      attr_accessor :hostname

      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?('hostnames')

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
unleash-0.1.3 lib/unleash/strategy/application_hostname.rb