Class: ActionFramework::Controller

Inherits:
Object
  • Object
show all
Defined in:
lib/actionframework/controller.rb

Direct Known Subclasses

ErrorHandler

Instance Method Summary collapse

Constructor Details

#initialize(env, req, res, url) ⇒ Controller

Returns a new instance of Controller.



8
9
10
11
12
13
# File 'lib/actionframework/controller.rb', line 8

def initialize env,req,res,url
	@req = req
	@res = res
	@url = url
	@env = env
end

Instance Method Details

#envObject



15
16
17
# File 'lib/actionframework/controller.rb', line 15

def env
	@env
end

#erb(template) ⇒ Object



35
36
37
38
39
# File 'lib/actionframework/controller.rb', line 35

def erb template
    		renderer = Tilt::ERBTemplate.new("views/layout.html.erb")
    		output = renderer.render(self){ Tilt::ERBTemplate.new("views/"+template.to_s+".html.erb").render(self) }
    		return output
end

#erb_text(erb_text) ⇒ Object



41
42
43
44
45
# File 'lib/actionframework/controller.rb', line 41

def erb_text erb_text
	renderer = Tilt::ERBTemplate.new("views/layout.html.erb")
    		output = renderer.render(self){ erb_text }
    		return output
end

#error_erb(code) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/actionframework/controller.rb', line 47

def error_erb code
	if(Dir.exists? "views/errors")
		renderer = Tilt::ERBTemplate.new("views/layout.html.erb")
     		output = renderer.render(self){ Tilt::ERBTemplate.new("views/errors/#{code}.html.erb").render(self) }
     		return output
    		else
    			root = ActionFramework::Gem.root
    			libdir = root.resources.to_s
    			renderer = Tilt::ERBTemplate.new(libdir+"/views/errors/layout.html.erb")
     		output = renderer.render(self){ Tilt::ERBTemplate.new(libdir+"/views/errors/#{code}.html.erb").render(self) }
    		end
end

#paramsObject



27
28
29
# File 'lib/actionframework/controller.rb', line 27

def params
	@req.params
end

#redirect(path) ⇒ Object



64
65
66
67
# File 'lib/actionframework/controller.rb', line 64

def redirect path
	response.redirect path
	""
end

#requestObject



19
20
21
# File 'lib/actionframework/controller.rb', line 19

def request
	@req
end

#responseObject



23
24
25
# File 'lib/actionframework/controller.rb', line 23

def response
	@res
end

#sessionObject



60
61
62
# File 'lib/actionframework/controller.rb', line 60

def session
	@req.session
end

#urlObject



31
32
33
# File 'lib/actionframework/controller.rb', line 31

def url
	@url
end