Sha256: 0b0830f8c3e85b7b086b582dbc59829f9f8c525e718ca6c85a07303cd0f2f69c

Contents?: true

Size: 946 Bytes

Versions: 12

Compression:

Stored size: 946 Bytes

Contents

module Sinatra
  module WebSocketIO

    def websocketio=(options)
      WebSocketIO.options = options
    end

    def websocketio
      WebSocketIO.options
    end

    def self.default_options
      {
        :port => [8080, lambda{|v| v.kind_of? Fixnum and v > 0 }]
      }
    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-websocketio-0.2.4 lib/sinatra-websocketio/options.rb
sinatra-websocketio-0.2.3 lib/sinatra-websocketio/options.rb
sinatra-websocketio-0.2.2 lib/sinatra-websocketio/options.rb
sinatra-websocketio-0.2.1 lib/sinatra-websocketio/options.rb
sinatra-websocketio-0.2.0 lib/sinatra-websocketio/options.rb
sinatra-websocketio-0.1.7 lib/sinatra-websocketio/options.rb
sinatra-websocketio-0.1.6 lib/sinatra-websocketio/options.rb
sinatra-websocketio-0.1.5 lib/sinatra-websocketio/options.rb
sinatra-websocketio-0.1.4 lib/sinatra-websocketio/options.rb
sinatra-websocketio-0.1.3 lib/sinatra-websocketio/options.rb
sinatra-websocketio-0.1.2 lib/sinatra-websocketio/options.rb
sinatra-websocketio-0.1.1 lib/sinatra-websocketio/options.rb