lib/gamebox/core/actor_factory.rb
# returns the newly created Actor after it and its ActorView has been created.
returns the newly created Actor after it and its ActorView has been created.
returns the newly created Actor after it and its ActorView has been created .
def build(actor, opts={})
    merged_opts = opts.merge(actor_type: actor)
    model = nil
    this_object_context.in_subcontext do |actor_context|
      begin
        model = actor_context[:actor]
        actor_definition = Actor.definitions[actor]
        raise "#{actor} not found in Actor.definitions" if actor_definition.nil?
        model.configure(merged_opts)
        actor_definition.attributes.each do |attr|
          model.has_attributes attr
        end
        model.has_attributes(view: "#{actor}_view") if actor_definition.view_blk
        actor_definition.behaviors.each do |behavior|
          beh_opts = {}
          beh_key = behavior
          if behavior.is_a?(Hash)
            beh_opts = behavior.values.first
            beh_key = behavior.keys.first
          end
          behavior_factory.add_behavior(model, beh_key, beh_opts)
        end
        actor_view_factory.build model, opts
      rescue Exception => e
        raise """
          #{actor} not found: 
          #{e.inspect}
          #{e.backtrace[0..6].join("\n")}
        """
      end
    end
    model
  end
def build ( actor , opts = { } ) merged_opts = opts . merge ( actor_type : actor ) model = nil this_object_context . in_subcontext do | actor_context | begin model = actor_context [ :actor ] actor_definition = Actor . definitions [ actor ] raise "#{actor} not found in Actor.definitions" if actor_definition . nil? model . configure ( merged_opts ) actor_definition . attributes . each do | attr | model . has_attributes attr end model . has_attributes ( view : "#{actor}_view" ) if actor_definition . view_blk actor_definition . behaviors . each do | behavior | beh_opts = { } beh_key = behavior if behavior . is_a? ( Hash ) beh_opts = behavior . values . first beh_key = behavior . keys . first end behavior_factory . add_behavior ( model , beh_key , beh_opts ) end actor_view_factory . build model , opts rescue Exception => e raise "" "
          #{actor} not found: 
          #{e.inspect}
          #{e.backtrace[0..6].join("\n")}
        " "" end end model end
returns the newly created Actor after it and its ActorView has been created.
returns the newly created Actor after it and its ActorView has been created .
# binding.pry
actor
<not_specific>
opts
<not_specific>