Sha256: 8b865ebbcace4276d75b64f201e13220185f6e6ab77949bc9e4fcf8f7e6bea37

Contents?: true

Size: 1.52 KB

Versions: 11

Compression:

Stored size: 1.52 KB

Contents

# frozen_string_literal: true

require 'rrj/models/concerns/janus_instance_concern'
if defined?(Mongoid)
  require 'rrj/models/mongoid'
else
  require 'rrj/models/active_record'
end

# :reek:FeatureEnvy

module RubyRabbitmqJanus
  module Tools
    # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>

    # # Utility for manage option to this gem.
    #
    # This class start all singleton, Log, Config, Request and Keepalice
    # instance. It's alos used for testing session/handle used in request.
    class Option
      def initialize
        Log.instance
        Config.instance
        Requests.instance
        Cluster.instance.create_sessions
      rescue => error
        raise Errors::Tools::Option::Initialize, error
      end

      # Determine session_id used
      #
      # @param [Hash] options Read options used in request
      #
      # @return [Fixnum] Session ID
      #
      # @since 2.0.0
      def use_current_session?(options)
        if options.key?('session_id')
          options['session_id']
        else
          Models::JanusInstance.first.session
        end
      rescue
        raise Errors::Tools::Option::UseCurrentSession, options
      end

      # Determine handle_id used
      #
      # @param [Hash] options Read options used in request
      #
      # @return [Fixnum] Handle ID
      #
      # @since 2.0.0
      def use_current_handle?(options)
        options.key?('handle_id') ? options['handle_id'] : 0
      rescue
        raise Errors::Tools::Option::UseCurrentHandle, options
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
ruby_rabbitmq_janus-2.1.1 lib/rrj/tools/gem/option.rb
ruby_rabbitmq_janus-2.1.1.pre.139 lib/rrj/tools/gem/option.rb
ruby_rabbitmq_janus-2.1.0 lib/rrj/tools/gem/option.rb
ruby_rabbitmq_janus-2.1.0.pre.137 lib/rrj/tools/gem/option.rb
ruby_rabbitmq_janus-2.1.0.pre.136 lib/rrj/tools/gem/option.rb
ruby_rabbitmq_janus-2.1.0.pre.135 lib/rrj/tools/gem/option.rb
ruby_rabbitmq_janus-2.1.0.pre.132 lib/rrj/tools/gem/option.rb
ruby_rabbitmq_janus-2.1.0.pre.131 lib/rrj/tools/gem/option.rb
ruby_rabbitmq_janus-2.1.0.pre.130 lib/rrj/tools/gem/option.rb
ruby_rabbitmq_janus-2.1.0.pre.129 lib/rrj/tools/gem/option.rb
ruby_rabbitmq_janus-2.1.0.pre.128 lib/rrj/tools/gem/option.rb