Class: Merrol::Controller

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

Instance Method Summary collapse

Constructor Details

#initialize(commands, views) ⇒ Controller

Returns a new instance of Controller.



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

def initialize commands, views
  @commands = commands
  @views = views

  @commands.register(self)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &block) ⇒ Object



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

def method_missing(meth, *args, &block)
  method = meth.to_s
  if method =~ /_view$/
    view = @views[method.gsub(/_view$/, '').to_sym]
    view || super
  else
    super
  end
end

Instance Method Details

#nameObject



21
22
23
# File 'lib/merrol/controllers/controller.rb', line 21

def name
  self.class.to_s.demodulize.underscore.gsub(/_controller$/, '').to_sym
end