Class: NetMate::Controller

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

Instance Method Summary collapse

Constructor Details

#initializeController

Returns a new instance of Controller.



4
5
6
# File 'lib/net_mate/controller.rb', line 4

def initialize
  @params = {}
end

Instance Method Details

#render(erb_name) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/net_mate/controller.rb', line 8

def render erb_name
  erb_name = erb_name.dup
  erb_name << '.html.erb'
  unless erb_name.start_with? '/'
    class_name = self.class.name      
    erb_dir = "#{(class_name[0..(class_name.rindex('Controller').pred)]).downcase}"
    erb_path = "#{ROOT_PATH}/app/views/#{erb_dir}/#{erb_name}"
  else
    erb_path = erb_name
  end
  body = Erubis::Eruby.new(IO.read(erb_path)).result(binding())
  Response.new(body).respond
end