Class: ShatteredController::Actor::Actor

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

Overview

An actor is a delegator to a controller game object.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options = {}) ⇒ Actor

Returns a new instance of Actor.



89
90
91
92
93
94
95
96
97
98
99
# File 'lib/actor/actor.rb', line 89

def initialize( name, options = {} )
  @actor_name = name
  @controller = (options[:controller] || ShatteredController::Base.new)
  @controller.model = options[:model]
  @controller.view = options[:view]
  @controller.view.model = options[:model] unless @controller.view.nil?

  if options[:view].nil? && options[:model].nil? && @controller.nil? && !options[:testing]
    raise NameError, "No model view or controller found for actor #{name}" 
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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

Delegate to controller



102
103
104
# File 'lib/actor/actor.rb', line 102

def method_missing(name, *args, &block)
  @controller.send(name, *args, &block)
end

Instance Attribute Details

#controllerObject (readonly)

:nodoc:all



88
89
90
# File 'lib/actor/actor.rb', line 88

def controller
  @controller
end