Class: GameMachine::GameSystems::JsonModelPersistence

Inherits:
Actor::Base
  • Object
show all
Includes:
Commands
Defined in:
lib/game_machine/game_systems/json_model_persistence.rb

Constant Summary

Constants inherited from Actor::Base

Actor::Base::ON_RECEIVE_HOOKS

Instance Method Summary collapse

Methods included from Commands

#commands

Methods inherited from Actor::Base

aspect, aspects, find, find_by_address, find_distributed, find_distributed_local, find_remote, hashring, local_path, model_filter, #onReceive, player_controller, #receive_message, #schedule_message, #sender, set_player_controller

Instance Method Details

#on_receive(message) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/game_machine/game_systems/json_model_persistence.rb', line 6

def on_receive(message)
  json_model = message
  if json_model.id
    if json_model.id.match(/find_by_id/)
      id = json_model.id.sub('find_by_id','')
      if json_model = json_model.class.find(id)
        commands.player.send_message(json_model,message.player_id)
      end
    else
      json_model.save
    end
  else
    unhandled(message)
  end
end