Module: Lockdown::Frameworks::Rails::System
- Includes:
- Controller
- Defined in:
- lib/lockdown/frameworks/rails.rb
Instance Method Summary
collapse
Methods included from Controller
#available_actions, #controller_name
Instance Method Details
#load_controller_classes ⇒ Object
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
# File 'lib/lockdown/frameworks/rails.rb', line 82
def load_controller_classes
@controller_classes = {}
maybe_load_framework_controller_parent
ApplicationController.helper_method :authorized?
ApplicationController.before_filter do |c|
c.set_current_user
c.configure_lockdown
c.check_request_authorization
end
ApplicationController.filter_parameter_logging :password,
:password_confirmation
ApplicationController.rescue_from SecurityError,
:with => proc{|e| access_denied(e)}
Dir.chdir("#{Lockdown.project_root}/app/controllers") do
Dir["**/*.rb"].sort.each do |c|
next if c == "application.rb"
lockdown_load(c)
end
end
if ENV['RAILS_ENV'] != 'production'
if ActiveSupport.const_defined?("Dependencies")
ActiveSupport::Dependencies.clear
else
Dependencies.clear
end
end
end
|
#lockdown_load(filename) ⇒ Object
#maybe_load_framework_controller_parent ⇒ Object
118
119
120
121
122
123
124
125
126
|
# File 'lib/lockdown/frameworks/rails.rb', line 118
def maybe_load_framework_controller_parent
if ::Rails::VERSION::MAJOR >= 2 && ::Rails::VERSION::MINOR >= 3
filename = "application_controller.rb"
else
filename = "application.rb"
end
require_or_load(filename)
end
|
#require_or_load(filename) ⇒ Object
136
137
138
139
140
141
142
|
# File 'lib/lockdown/frameworks/rails.rb', line 136
def require_or_load(filename)
if ActiveSupport.const_defined?("Dependencies")
ActiveSupport::Dependencies.require_or_load(filename)
else
Dependencies.require_or_load(filename)
end
end
|
#skip_sync? ⇒ Boolean
78
79
80
|
# File 'lib/lockdown/frameworks/rails.rb', line 78
def skip_sync?
Lockdown::System.fetch(:skip_db_sync_in).include?(ENV['RAILS_ENV'])
end
|