Sha256: 9e425d84e9053d4abeabcbbd93e3c749236159a0e18d30997ee5e46ac5decae3

Contents?: true

Size: 930 Bytes

Versions: 12

Compression:

Stored size: 930 Bytes

Contents

module Sinatra
  module CometIO

    def cometio=(options)
      CometIO.options = options
    end

    def cometio
      CometIO.options
    end

    def self.default_options
      {
        :timeout => [120, lambda{|v| v.kind_of? Fixnum and v >= 20 }]
      }
    end

    def self.options
      @@options ||= (
                     opts = {}
                     default_options.each do |k,v|
                       opts[k] = v[0]
                     end
                     opts
                     )
    end

    def self.options=(opts)
      @@options = {}
      opts.each do |k,v|
        k = k.to_sym
        if default_options.include? k
          @@options[k] = default_options[k][1].call(v) ? v : default_options[k][0]
        else
          @@options[k] = v
        end
      end
      default_options.each do |k, v|
        @@options[k] = v unless @@options.include? k
      end
      @@options
    end

  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
sinatra-cometio-0.5.0 lib/sinatra-cometio/options.rb
sinatra-cometio-0.4.3 lib/sinatra-cometio/options.rb
sinatra-cometio-0.4.2 lib/sinatra-cometio/options.rb
sinatra-cometio-0.4.1 lib/sinatra-cometio/options.rb
sinatra-cometio-0.4.0 lib/sinatra-cometio/options.rb
sinatra-cometio-0.3.9 lib/sinatra-cometio/options.rb
sinatra-cometio-0.3.8 lib/sinatra-cometio/options.rb
sinatra-cometio-0.3.7 lib/sinatra-cometio/options.rb
sinatra-cometio-0.3.6 lib/sinatra-cometio/options.rb
sinatra-cometio-0.3.5 lib/sinatra-cometio/options.rb
sinatra-cometio-0.3.4 lib/sinatra-cometio/options.rb
sinatra-cometio-0.3.3 lib/sinatra-cometio/options.rb