Class: ShatteredController::Actor::Actor
- Inherits:
-
Object
- Object
- ShatteredController::Actor::Actor
- Defined in:
- lib/actor/actor.rb
Overview
An actor is a delegator to a controller game object.
Instance Attribute Summary collapse
-
#controller ⇒ Object
readonly
:nodoc:all.
Instance Method Summary collapse
-
#initialize(name, options = {}) ⇒ Actor
constructor
A new instance of Actor.
-
#method_missing(name, *args, &block) ⇒ Object
Delegate to controller.
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, = {} ) @actor_name = name @controller = ([:controller] || ShatteredController::Base.new) @controller.model = [:model] @controller.view = [:view] @controller.view.model = [:model] unless @controller.view.nil? if [:view].nil? && [:model].nil? && @controller.nil? && ![: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
#controller ⇒ Object (readonly)
:nodoc:all
88 89 90 |
# File 'lib/actor/actor.rb', line 88 def controller @controller end |