Sha256: 0244656a0c94c605c26fa374131823a26d0023b5b8808148d1832e56de0435c0

Contents?: true

Size: 624 Bytes

Versions: 1

Compression:

Stored size: 624 Bytes

Contents

require 'riddle'

module Thebes

  class Query < Riddle::Client
    cattr_accessor :before_query,
                   :before_running,
                   :servers

    def initialize *args
      if !args.empty? || self.class.servers.empty?
        super *args
      else
        super *self.class.servers[rand(self.class.servers.size)]
      end
    end

    class << self

      def run &block
        client = new # would take server and port
        before_query.call(client) if before_query
        block.call client
        before_running.call(client) if before_running
        client.run
      end

    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
thebes-0.0.3 lib/thebes/query.rb