Module: Magent

Defined in:
lib/magent.rb,
lib/magent/push.rb,
lib/magent/actor.rb,
lib/magent/utils.rb,
lib/magent/channel.rb,
lib/magent/processor.rb,
lib/magent/generic_channel.rb

Defined Under Namespace

Modules: Actor, Utils Classes: Channel, GenericChannel, Processor

Constant Summary collapse

VERSION =
'0.4.1'
@@db_name =
'magent'
@@host =
'localhost'
@@port =
'27017'
@@username =
''
@@password =
''

Class Method Summary collapse

Class Method Details

.auth(username, password) ⇒ Object



29
30
31
32
# File 'lib/magent.rb', line 29

def self.auth(username,password)
  @@username = username
  @@password = password
end

.channel(name) ⇒ Object



6
7
8
# File 'lib/magent/push.rb', line 6

def self.channel(name)
  self.channels[name] ||= Channel.new(name)
end

.channelsObject



10
11
12
# File 'lib/magent/push.rb', line 10

def self.channels
  @channels ||= {}
end

.connectionObject



38
39
40
41
42
43
# File 'lib/magent.rb', line 38

def self.connection
  return @@connection if defined? @@connection  
  @@connection = Mongo::Connection.new(@@host, @@port, :auto_reconnect => true)
  @@connection.add_auth(@@db_name, @@username, @@password) if @@username!='' && @@password!=''
  return @@connection
end

.connection=(new_connection) ⇒ Object



45
46
47
# File 'lib/magent.rb', line 45

def self.connection=(new_connection)
  @@connection = new_connection
end

.current_actorObject



75
76
77
# File 'lib/magent/actor.rb', line 75

def self.current_actor
  @current_actor
end

.databaseObject



53
54
55
# File 'lib/magent.rb', line 53

def self.database
  @@database ||= Magent.connection.db(@@db_name)
end

.database=(name) ⇒ Object



49
50
51
# File 'lib/magent.rb', line 49

def self.database=(name)
  @@database = Magent.connection.db(name)
end

.db_name(db_name) ⇒ Object



34
35
36
# File 'lib/magent.rb', line 34

def self.db_name(db_name)
  @@db_name = db_name
end

.host(host, port) ⇒ Object



24
25
26
27
# File 'lib/magent.rb', line 24

def self.host(host,port)
  @@host = host
  @@port = port
end

.push(channel_name, method, *args) ⇒ Object



2
3
4
# File 'lib/magent/push.rb', line 2

def self.push(channel_name, method, *args)
  self.channel(channel_name.to_s).enqueue(method, args)
end

.register(actor) ⇒ Object

Actor



71
72
73
# File 'lib/magent/actor.rb', line 71

def self.register(actor)
  @current_actor = actor
end