Module: Lockdown::Frameworks::Rails::Environment
- Defined in:
- lib/lockdown/frameworks/rails.rb
Overview
class block
Instance Method Summary collapse
-
#add_controller_method(code) ⇒ Object
cache_classes is true in production and testing, need to do an instance eval instead.
- #caching_classes? ⇒ Boolean
- #controller_class_name(str) ⇒ Object
-
#controller_parent ⇒ Object
cache_classes is true in production and testing, need to modify the ApplicationController.
- #fetch_controller_class(str) ⇒ Object
- #init_file ⇒ Object
- #project_root ⇒ Object
- #view_helper ⇒ Object
Instance Method Details
#add_controller_method(code) ⇒ Object
cache_classes is true in production and testing, need to do an instance eval instead
82 83 84 |
# File 'lib/lockdown/frameworks/rails.rb', line 82 def add_controller_method(code) Lockdown.controller_parent.class_eval code, __FILE__,__LINE__ +1 end |
#caching_classes? ⇒ Boolean
76 77 78 |
# File 'lib/lockdown/frameworks/rails.rb', line 76 def caching_classes? ::Rails.configuration.cache_classes end |
#controller_class_name(str) ⇒ Object
86 87 88 89 90 91 92 93 |
# File 'lib/lockdown/frameworks/rails.rb', line 86 def controller_class_name(str) str = "#{str}Controller" if str.include?("__") str.split("__").collect{|p| Lockdown.camelize(p)}.join("::") else Lockdown.camelize(str) end end |
#controller_parent ⇒ Object
cache_classes is true in production and testing, need to modify the ApplicationController
68 69 70 71 72 73 74 |
# File 'lib/lockdown/frameworks/rails.rb', line 68 def controller_parent if caching_classes? ApplicationController else ActionController::Base end end |
#fetch_controller_class(str) ⇒ Object
95 96 97 |
# File 'lib/lockdown/frameworks/rails.rb', line 95 def fetch_controller_class(str) eval("::#{controller_class_name(str)}") end |
#init_file ⇒ Object
58 59 60 |
# File 'lib/lockdown/frameworks/rails.rb', line 58 def init_file "#{project_root}/lib/lockdown/init.rb" end |
#project_root ⇒ Object
54 55 56 |
# File 'lib/lockdown/frameworks/rails.rb', line 54 def project_root ::RAILS_ROOT end |
#view_helper ⇒ Object
62 63 64 |
# File 'lib/lockdown/frameworks/rails.rb', line 62 def view_helper ::ActionView::Base end |