Module: Lockdown::Frameworks::Rails::Environment

Defined in:
lib/lockdown/frameworks/rails.rb

Overview

class block

Instance Method Summary collapse

Instance Method Details

#add_controller_method(code) ⇒ Object

cache_classes is true in production and testing, need to do an instance eval instead



78
79
80
# File 'lib/lockdown/frameworks/rails.rb', line 78

def add_controller_method(code)
  Lockdown.controller_parent.class_eval code, __FILE__,__LINE__ +1
end

#controller_class_name(str) ⇒ Object



82
83
84
85
86
87
88
89
# File 'lib/lockdown/frameworks/rails.rb', line 82

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_parentObject

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 ::Rails.configuration.cache_classes
    ApplicationController
  else
    ActionController::Base
  end
end

#fetch_controller_class(str) ⇒ Object



91
92
93
# File 'lib/lockdown/frameworks/rails.rb', line 91

def fetch_controller_class(str)
  eval("::#{controller_class_name(str)}")
end

#init_fileObject



58
59
60
# File 'lib/lockdown/frameworks/rails.rb', line 58

def init_file
  "#{project_root}/lib/lockdown/init.rb"
end

#project_rootObject



54
55
56
# File 'lib/lockdown/frameworks/rails.rb', line 54

def project_root
  ::RAILS_ROOT
end

#view_helperObject



62
63
64
# File 'lib/lockdown/frameworks/rails.rb', line 62

def view_helper
  ::ActionView::Base 
end