Sha256: 8920f419c854b3cc21cea6c2b07be0de8e811ee73471dba584b4e3f0ab363b9a

Contents?: true

Size: 1.42 KB

Versions: 46

Compression:

Stored size: 1.42 KB

Contents

# frozen_string_literal: true

module RubyRabbitmqJanus
  module Tools
    module Replaces
      # Format message request with good data to HASH format for Admin request.
      # Manage level, debug and admin_secret
      #
      # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
      class Admin < Handle
        private

        def replace_element_classic
          super
          replace_admins if request.key?('admin_secret')
          add_secret if opts.key?('add')
        end

        def add_secret
          values = opts['add']
          request.merge!(values)
        end

        def replace_admins
          replace_admin
          replace_level if request.key?('level')
          replace_debug if request.key?('debug')
        end

        def replace_admin
          request['admin_secret'] = admin_pass
        rescue => message
          Tools::Log.instance.warn "Error replace admin_secret : #{message}"
        end

        def replace_level
          request['level'] = type.convert('level', opts)
        rescue => message
          Tools::Log.instance.warn "Error replace level : #{message}"
        end

        def replace_debug
          request['debug'] = type.convert('debug', opts)
        rescue => message
          Tools::Log.instance.warn "Error replace debug : #{message}"
        end

        def admin_pass
          Tools::Config.instance.options['rabbit']['admin_pass']
        end
      end
    end
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
ruby_rabbitmq_janus-2.4.0.pre.208 lib/rrj/tools/replaces/admin.rb
ruby_rabbitmq_janus-2.3.1.pre.201 lib/rrj/tools/replaces/admin.rb
ruby_rabbitmq_janus-2.3.1.pre.198 lib/rrj/tools/replaces/admin.rb
ruby_rabbitmq_janus-2.3.0.pre.197 lib/rrj/tools/replaces/admin.rb
ruby_rabbitmq_janus-2.3.0.pre.196 lib/rrj/tools/replaces/admin.rb
ruby_rabbitmq_janus-2.3.0 lib/rrj/tools/replaces/admin.rb
ruby_rabbitmq_janus-2.3.0.pre.194 lib/rrj/tools/replaces/admin.rb
ruby_rabbitmq_janus-2.3.0.pre.192 lib/rrj/tools/replaces/admin.rb
ruby_rabbitmq_janus-2.3.0.pre.170 lib/rrj/tools/replaces/admin.rb
ruby_rabbitmq_janus-2.2.2 lib/rrj/tools/replaces/admin.rb
ruby_rabbitmq_janus-2.2.1 lib/rrj/tools/replaces/admin.rb
ruby_rabbitmq_janus-2.2.1.pre.181 lib/rrj/tools/replaces/admin.rb
ruby_rabbitmq_janus-2.2.1.pre.180 lib/rrj/tools/replaces/admin.rb
ruby_rabbitmq_janus-2.2.0.pre.179 lib/rrj/tools/replaces/admin.rb
ruby_rabbitmq_janus-2.2.0 lib/rrj/tools/replaces/admin.rb
ruby_rabbitmq_janus-2.2.0.pre.177 lib/rrj/tools/replaces/admin.rb
ruby_rabbitmq_janus-2.2.0.pre.173 lib/rrj/tools/replaces/admin.rb
ruby_rabbitmq_janus-2.2.0.pre.170 lib/rrj/tools/replaces/admin.rb
ruby_rabbitmq_janus-2.2.0.pre.168 lib/rrj/tools/replaces/admin.rb
ruby_rabbitmq_janus-2.2.0.pre.167 lib/rrj/tools/replaces/admin.rb