Class: Mycommands::Controller

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

Instance Method Summary collapse

Constructor Details

#initializeController

Returns a new instance of Controller.



3
4
5
6
7
8
# File 'lib/mycommands/controllers/controller.rb', line 3

def initialize
  @name = self.class.to_s.gsub('Controller', '')
  set_model
  @view = Factory::get(@name+'View')
  @application =  Factory::get(:Application)
end

Instance Method Details

#render(action = nil) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/mycommands/controllers/controller.rb', line 10

def render action = nil
  instance_variables.each do |i|
    @view.instance_variable_set i, eval(i.to_s) unless %w(model view application).include? i
  end
  if action
    @view.send(action)
  else
    @view.send(caller(1).first[/`.*'/][1..-2].to_sym)
  end
end