Class: GameMachine::Commands::DatastoreCommands
- Inherits:
-
Object
- Object
- GameMachine::Commands::DatastoreCommands
- Defined in:
- server/lib/game_machine/commands/datastore_commands.rb
Instance Attribute Summary collapse
-
#store ⇒ Object
readonly
Returns the value of attribute store.
Instance Method Summary collapse
- #call_dbproc(name, current_entity_id, update_entity, blocking = true) ⇒ Object
- #define_dbproc(name, &blk) ⇒ Object
- #delete(entity_id) ⇒ Object
- #delete!(entity_id) ⇒ Object
- #get(entity_id, timeout = 1000) ⇒ Object
- #get!(entity_id) ⇒ Object
-
#initialize ⇒ DatastoreCommands
constructor
A new instance of DatastoreCommands.
- #put(entity) ⇒ Object
- #put!(entity) ⇒ Object
Constructor Details
#initialize ⇒ DatastoreCommands
Returns a new instance of DatastoreCommands.
6 7 8 |
# File 'server/lib/game_machine/commands/datastore_commands.rb', line 6 def initialize @store = DbLib::Store.get_instance end |
Instance Attribute Details
#store ⇒ Object (readonly)
Returns the value of attribute store
5 6 7 |
# File 'server/lib/game_machine/commands/datastore_commands.rb', line 5 def store @store end |
Instance Method Details
#call_dbproc(name, current_entity_id, update_entity, blocking = true) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'server/lib/game_machine/commands/datastore_commands.rb', line 14 def call_dbproc(name,current_entity_id,update_entity,blocking=true) ref = ObjectDb.find_distributed(current_entity_id) = MessageLib::ObjectdbUpdate.new. set_current_entity_id(current_entity_id). set_update_method(name). set_update_entity(update_entity) if blocking ref.ask(, 100) else ref.tell() end end |
#define_dbproc(name, &blk) ⇒ Object
10 11 12 |
# File 'server/lib/game_machine/commands/datastore_commands.rb', line 10 def define_dbproc(name,&blk) ObjectDb.dbprocs[name] = blk end |
#delete(entity_id) ⇒ Object
49 50 51 52 |
# File 'server/lib/game_machine/commands/datastore_commands.rb', line 49 def delete(entity_id) ref = Actor::Base.find_distributed(entity_id,'object_store') ref.tell(MessageLib::ObjectdbDel.new.set_entity_id(entity_id)) end |
#delete!(entity_id) ⇒ Object
35 36 37 |
# File 'server/lib/game_machine/commands/datastore_commands.rb', line 35 def delete!(entity_id) store.delete(entity_id) end |
#get(entity_id, timeout = 1000) ⇒ Object
44 45 46 47 |
# File 'server/lib/game_machine/commands/datastore_commands.rb', line 44 def get(entity_id,timeout=1000) ref = Actor::Base.find_distributed(entity_id,'object_store') ref.ask(MessageLib::ObjectdbGet.new.set_entity_id(entity_id), timeout) end |
#get!(entity_id) ⇒ Object
31 32 33 |
# File 'server/lib/game_machine/commands/datastore_commands.rb', line 31 def get!(entity_id) store.get(entity_id) end |
#put(entity) ⇒ Object
39 40 41 42 |
# File 'server/lib/game_machine/commands/datastore_commands.rb', line 39 def put(entity) ref = Actor::Base.find_distributed(entity.get_id,'object_store') ref.tell(MessageLib::ObjectdbPut.new.set_entity(entity)) end |
#put!(entity) ⇒ Object
27 28 29 |
# File 'server/lib/game_machine/commands/datastore_commands.rb', line 27 def put!(entity) store.set(entity.id,entity) end |