Sha256: ca62740ef731d5f5a62059ac944e3e60f1c377c748fda07d8acf6ad19a1e0a35

Contents?: true

Size: 1.3 KB

Versions: 18

Compression:

Stored size: 1.3 KB

Contents

module Sinatra
  module RocketIO
    module Linda

      def linda=(options)
        Linda.options = options
      end

      def linda
        Linda.options
      end

      def self.default_options
        {
          :expire_check => [60, 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 "!! Sinatra::RocketIO::Linda setting - \"#{k}\" is not valid key"
          else
            unless default_options[k][1].call(v)
              default = default_options[k][0]
              STDERR.puts "!! Sinatra::RocketIO::Linda 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[0] unless @@options.include? k
        end
        @@options
      end

    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
sinatra-rocketio-linda-1.1.0 lib/sinatra-rocketio-linda/options.rb
sinatra-rocketio-linda-1.0.1 lib/sinatra-rocketio-linda/options.rb
sinatra-rocketio-linda-1.0.0 lib/sinatra-rocketio-linda/options.rb
sinatra-rocketio-linda-0.2.0 lib/sinatra-rocketio-linda/options.rb
sinatra-rocketio-linda-0.1.4 lib/sinatra-rocketio-linda/options.rb
sinatra-rocketio-linda-0.1.3 lib/sinatra-rocketio-linda/options.rb
sinatra-rocketio-linda-0.1.2 lib/sinatra-rocketio-linda/options.rb
sinatra-rocketio-linda-0.1.1 lib/sinatra-rocketio-linda/options.rb
sinatra-rocketio-linda-0.1.0 lib/sinatra-rocketio-linda/options.rb
sinatra-rocketio-linda-0.0.9 lib/sinatra-rocketio-linda/options.rb
sinatra-rocketio-linda-0.0.8 lib/sinatra-rocketio-linda/options.rb
sinatra-rocketio-linda-0.0.7 lib/sinatra-rocketio-linda/options.rb
sinatra-rocketio-linda-0.0.6 lib/sinatra-rocketio-linda/options.rb
sinatra-rocketio-linda-0.0.5 lib/sinatra-rocketio-linda/options.rb
sinatra-rocketio-linda-0.0.4 lib/sinatra-rocketio-linda/options.rb
sinatra-rocketio-linda-0.0.3 lib/sinatra-rocketio-linda/options.rb
sinatra-rocketio-linda-0.0.2 lib/sinatra-rocketio-linda/options.rb
sinatra-rocketio-linda-0.0.1 lib/sinatra-rocketio-linda/options.rb