Sha256: acdd6015a8c68fc9b1ee361e6da87421262cc090e199ed61a09ebab76a61eff7
Contents?: true
Size: 1.18 KB
Versions: 1
Compression:
Stored size: 1.18 KB
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 unless default_options.include? k STDERR.puts "!! #{self} setting - \"#{k}\" is not valid key" else unless default_options[k][1].call(v) default = default_options[k][0] STDERR.puts "!! #{self} setting - \"#{k} => #{v}\" is not valid. set default \"#{k} => #{default}\"" @@options[k] = default else @@options[k] = v end end end default_options.each do |k, v| @@options[k] = v unless @@options.include? k end @@options end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sinatra-websocketio-0.2.5 | lib/sinatra-websocketio/options.rb |