Sha256: e3ee72388b3c0130b97cbf076aaaf9123c78200cbe9feb722ae50f3ae6f6c0e4

Contents?: true

Size: 1.16 KB

Versions: 28

Compression:

Stored size: 1.16 KB

Contents

# frozen_string_literal: true

# :reek:UtilityFunction

module RubyRabbitmqJanus
  module Models
    # Add class methods for JanusInstance model
    module Instances
      extend ActiveSupport::Concern

      # Class methods for Janus Instance model
      module ClassMethods
        # Disable an instance
        def disable(session_id)
          JanusInstance.find_by(session: session_id).set(enable: false)
        end

        # Clean all instance disabled
        def destroys
          JanusInstance.where(enable: false).delete_all
        end

        # Search a record by instance number
        def find_by_instance(instance_search)
          JanusInstance.find_by(instance: instance_search)
        rescue
          false
        end

        # Search a record by session number
        def find_by_session(session_search)
          JanusInstance.find_by(session: session_search)
        rescue
          nil
        end

        # Get all instance active
        def enabled
          JanusInstance.where(enable: true)
        end

        # Get all instance not active
        def disabled
          JanusInstance.where(enable: false)
        end
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
ruby_rabbitmq_janus-3.0.0.pre.336 lib/rrj/models/concerns/instances.rb
ruby_rabbitmq_janus-3.0.0.pre.335 lib/rrj/models/concerns/instances.rb
ruby_rabbitmq_janus-3.0.0.pre.334 lib/rrj/models/concerns/instances.rb
ruby_rabbitmq_janus-3.0.0.pre.330 lib/rrj/models/concerns/instances.rb
ruby_rabbitmq_janus-3.0.0.pre.328 lib/rrj/models/concerns/instances.rb
ruby_rabbitmq_janus-3.0.0.pre.327 lib/rrj/models/concerns/instances.rb
ruby_rabbitmq_janus-2.7.2 lib/rrj/models/concerns/instances.rb
ruby_rabbitmq_janus-2.7.2.pre.322 lib/rrj/models/concerns/instances.rb
ruby_rabbitmq_janus-2.7.2.pre.320 lib/rrj/models/concerns/instances.rb
ruby_rabbitmq_janus-2.7.2.pre.319 lib/rrj/models/concerns/instances.rb
ruby_rabbitmq_janus-2.7.2.pre.318 lib/rrj/models/concerns/instances.rb
ruby_rabbitmq_janus-2.7.2.pre.317 lib/rrj/models/concerns/instances.rb
ruby_rabbitmq_janus-2.7.2.pre.316 lib/rrj/models/concerns/instances.rb
ruby_rabbitmq_janus-2.7.2.pre.315 lib/rrj/models/concerns/instances.rb
ruby_rabbitmq_janus-2.7.2.pre.314 lib/rrj/models/concerns/instances.rb
ruby_rabbitmq_janus-2.7.2.pre.312 lib/rrj/models/concerns/instances.rb
ruby_rabbitmq_janus-2.7.2.pre.310 lib/rrj/models/concerns/instances.rb
ruby_rabbitmq_janus-2.7.2.pre.309 lib/rrj/models/concerns/instances.rb
ruby_rabbitmq_janus-2.7.2.pre.308 lib/rrj/models/concerns/instances.rb
ruby_rabbitmq_janus-2.7.2.pre.307 lib/rrj/models/concerns/instances.rb