Class: Rack::MiniProfiler::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/mini_profiler/config.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#authorization_modeObject

Returns the value of attribute authorization_mode.



15
16
17
# File 'lib/mini_profiler/config.rb', line 15

def authorization_mode
  @authorization_mode
end

#auto_injectObject

Returns the value of attribute auto_inject.



15
16
17
# File 'lib/mini_profiler/config.rb', line 15

def auto_inject
  @auto_inject
end

#backtrace_filterObject

Returns the value of attribute backtrace_filter.



15
16
17
# File 'lib/mini_profiler/config.rb', line 15

def backtrace_filter
  @backtrace_filter
end

#backtrace_removeObject

Returns the value of attribute backtrace_remove.



15
16
17
# File 'lib/mini_profiler/config.rb', line 15

def backtrace_remove
  @backtrace_remove
end

#base_url_pathObject

Returns the value of attribute base_url_path.



15
16
17
# File 'lib/mini_profiler/config.rb', line 15

def base_url_path
  @base_url_path
end

#positionObject

Returns the value of attribute position.



15
16
17
# File 'lib/mini_profiler/config.rb', line 15

def position
  @position
end

#pre_authorize_cbObject

Returns the value of attribute pre_authorize_cb.



15
16
17
# File 'lib/mini_profiler/config.rb', line 15

def pre_authorize_cb
  @pre_authorize_cb
end

#skip_pathsObject

Returns the value of attribute skip_paths.



15
16
17
# File 'lib/mini_profiler/config.rb', line 15

def skip_paths
  @skip_paths
end

#skip_schema_queriesObject

Returns the value of attribute skip_schema_queries.



15
16
17
# File 'lib/mini_profiler/config.rb', line 15

def skip_schema_queries
  @skip_schema_queries
end

#storageObject

Returns the value of attribute storage.



15
16
17
# File 'lib/mini_profiler/config.rb', line 15

def storage
  @storage
end

#storage_instanceObject

Returns the value of attribute storage_instance.



15
16
17
# File 'lib/mini_profiler/config.rb', line 15

def storage_instance
  @storage_instance
end

#storage_optionsObject

Returns the value of attribute storage_options.



15
16
17
# File 'lib/mini_profiler/config.rb', line 15

def storage_options
  @storage_options
end

#use_existing_jqueryObject

Returns the value of attribute use_existing_jquery.



15
16
17
# File 'lib/mini_profiler/config.rb', line 15

def use_existing_jquery
  @use_existing_jquery
end

#user_providerObject

Returns the value of attribute user_provider.



15
16
17
# File 'lib/mini_profiler/config.rb', line 15

def user_provider
  @user_provider
end

Class Method Details

.attr_accessor(*vars) ⇒ Object



5
6
7
8
9
# File 'lib/mini_profiler/config.rb', line 5

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

.attributesObject



11
12
13
# File 'lib/mini_profiler/config.rb', line 11

def self.attributes
  @attributes
end

.defaultObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/mini_profiler/config.rb', line 19

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

Instance Method Details

#merge!(config) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/mini_profiler/config.rb', line 38

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