Sha256: b0a5a6c1b2be986c1825ec8cdbe5ea732441c12c7b27e5249d4c278b579e1b81

Contents?: true

Size: 734 Bytes

Versions: 4

Compression:

Stored size: 734 Bytes

Contents

class CometIO

  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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sinatra-cometio-0.2.0 lib/sinatra-cometio/options.rb
sinatra-cometio-0.1.9 lib/sinatra-cometio/options.rb
sinatra-cometio-0.1.8 lib/sinatra-cometio/options.rb
sinatra-cometio-0.1.7 lib/sinatra-cometio/options.rb