Module: RackConsole::Configuration

Included in:
AppHelpers
Defined in:
lib/rack_console/configuration.rb

Instance Method Summary collapse

Instance Method Details

#check_access!Object



18
19
20
# File 'lib/rack_console/configuration.rb', line 18

def check_access!
  unauthorized! unless has_console_access?
end

#css_dirObject



50
51
52
# File 'lib/rack_console/configuration.rb', line 50

def css_dir
  config[:css_dir]
end

#eval_targetObject



54
55
56
57
58
59
60
61
# File 'lib/rack_console/configuration.rb', line 54

def eval_target
  case et = config[:eval_target]
  when Proc
    et.call
  else
    et
  end
end

#find_template(views, name, engine, &block) ⇒ Object



42
43
44
45
46
47
48
# File 'lib/rack_console/configuration.rb', line 42

def find_template(views, name, engine, &block)
  views = config[:views] || views
  Array(views).each do |v|
    v = config[:views_default] if v == :default
    super(v, name, engine, &block)
  end
end

#has_console_access?Boolean

Returns:

  • (Boolean)


7
8
9
10
11
12
13
14
15
16
# File 'lib/rack_console/configuration.rb', line 7

def has_console_access?
  case a = config[:authorized?]
  when true, false
    a
  when Proc
    a.call
  else
    true
  end
end

#has_file_access?(file) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/rack_console/configuration.rb', line 26

def has_file_access? file
  ! ! (file != '(eval)' && $".include?(file))
end

#layoutObject



38
39
40
# File 'lib/rack_console/configuration.rb', line 38

def layout
  config[:layout] || :layout
end

#localsObject



34
35
36
# File 'lib/rack_console/configuration.rb', line 34

def locals
  @locals ||= { }
end

#server_infoObject



63
64
65
66
67
68
69
70
71
# File 'lib/rack_console/configuration.rb', line 63

def server_info
  thr = Thread.current
  (config[:server_info] || { }).merge(
    host: Socket.gethostname,
    pid: Process.pid,
    ppid: Process.ppid,
    thread: thr[:name] || thr.object_id,
  )
end

#unauthorized!Object

Raises:



22
23
24
# File 'lib/rack_console/configuration.rb', line 22

def unauthorized!
  raise Error, "not authorized"
end

#url_root(url) ⇒ Object



30
31
32
# File 'lib/rack_console/configuration.rb', line 30

def url_root url
  "#{config[:url_root_prefix]}#{url}"
end