Sha256: 505348999ee0c7b1572918d6026bfce96a8cfae191d0e1db5977f3678b2f64fb

Contents?: true

Size: 1.62 KB

Versions: 9

Compression:

Stored size: 1.62 KB

Contents

module Rack
  class MiniProfiler
    class Config

    def self.attr_accessor(*vars)
      @attributes ||= []
      @attributes.concat vars
      super(*vars)
    end
    
    def self.attributes
      @attributes
    end

    attr_accessor :auto_inject, :base_url_path, :pre_authorize_cb, :position,
        :backtrace_remove, :backtrace_filter, :skip_schema_queries, 
        :storage, :user_provider, :storage_instance, :storage_options, :skip_paths, :authorization_mode, :use_existing_jquery
      
      def self.default
        new.instance_eval {
          @auto_inject = true # automatically inject on every html page
          @base_url_path = "/mini-profiler-resources/"
          
          # called prior to rack chain, to ensure we are allowed to profile
          @pre_authorize_cb = lambda {|env| true} 
                                                  
          # called after rack chain, to ensure we are REALLY allowed to profile
          @position = 'left'  # Where it is displayed
          @skip_schema_queries = false
          @storage = MiniProfiler::MemoryStore
          @user_provider = Proc.new{|env| Rack::Request.new(env).ip}
          @authorization_mode = :allow_all
          @use_existing_jquery = false
          self
        }
      end

      def merge!(config)
        return unless config
        if Hash === config 
          config.each{|k,v| instance_variable_set "@#{k}",v}
        else 
          self.class.attributes.each{ |k|  
            v = config.send k
            instance_variable_set "@#{k}", v if v
          }
        end
      end

    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
rack-mini-profiler-0.1.12.pre lib/mini_profiler/config.rb
rack-mini-profiler-0.1.11.pre lib/mini_profiler/config.rb
rack-mini-profiler-0.1.10 lib/mini_profiler/config.rb
rack-mini-profiler-0.1.9 lib/mini_profiler/config.rb
rack-mini-profiler-0.1.8 lib/mini_profiler/config.rb
miniprofiler-0.1.7.4 lib/mini_profiler/config.rb
miniprofiler-0.1.7.3 lib/mini_profiler/config.rb
miniprofiler-0.1.7.2 lib/mini_profiler/config.rb
miniprofiler-0.1.7.1 lib/mini_profiler/config.rb