Class: Mousevc::Controller

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

Overview

Base controller class in Mousevc. Handles communication with the model. Decides which view to output.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Controller

Note:

Controllers should not be instantiated directly. Pass the name of the controller you wish you instantiate to the router via @router.controller along with a model and action. This allows the router to do the work for you on the next application execution or loop.

Creates a new Mousevc::Controller instance

Parameters:

  • options (Hash) (defaults to: {})

    expects the following keys:

    • :model => [Mousevc::Model] a reference to the controller's model instance

    • :view => [Mousevc::View] a reference to the view instance

    • :router => [Mousevc::Router] a reference to the router instance


40
41
42
43
44
# File 'lib/mousevc/controller.rb', line 40

def initialize(options={})
	@model = options[:model]
	@view = options[:view]
	@router = options[:router]
end

Instance Attribute Details

#modelMousevc::Model

An instance of the Mousevc::Model class. This will be an instance of the model class passed to the application during initialization. It is also possible to change this via @router.model

Returns:


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

def model
  @model
end

#viewMousevc::View (readonly)

An instance of the Mousevc::View class

Returns:


28
29
30
# File 'lib/mousevc/controller.rb', line 28

def view
  @view
end