Class: AgentXmpp::Publication

Inherits:
Object
  • Object
show all
Defined in:
lib/agent_xmpp/models/publication.rb

Overview


Class Method Summary collapse

Class Method Details

.find_allObject

.….….….….….….….….….….….….….….….….….….….….….….….….….….



32
33
34
# File 'lib/agent_xmpp/models/publication.rb', line 32

def find_all
  publications.all
end

.find_by_node(node) ⇒ Object

.….….….….….….….….….….….….….….….….….….….….….….….….….….



27
28
29
# File 'lib/agent_xmpp/models/publication.rb', line 27

def find_by_node(node)
  publications[:node => node]
end

.load_configObject

.….….….….….….….….….….….….….….….….….….….….….….….….….….



16
17
18
19
20
21
22
23
24
# File 'lib/agent_xmpp/models/publication.rb', line 16

def load_config
  if AgentXmpp.config['publish'].kind_of?(Array)
    AgentXmpp.config['publish'].each do |pub|
      publications << AgentXmpp::DEFAULT_PUBSUB_CONFIG.inject({}) do |f, (a, v)| 
        f.merge(a => pub[a.to_s] || v)
      end.merge(:status => 'new', :node => pub['node']) 
    end
  end
end

.publications(renew = false) ⇒ Object

.….….….….….….….….….….….….….….….….….….….….….….….….….….



11
12
13
# File 'lib/agent_xmpp/models/publication.rb', line 11

def publications(renew=false)
  @publications ||= AgentXmpp.in_memory_db[:publications]
end

.stats_by_nodeObject

.….….….….….….….….….….….….….….….….….….….….….….….….….….



42
43
44
# File 'lib/agent_xmpp/models/publication.rb', line 42

def stats_by_node
  find_all.map{|p| Message.stats_by_node("#{AgentXmpp.user_pubsub_root}/#{p[:node]}").update(:node=>p[:node].split('/').last)}
end

.update_status(node, status) ⇒ Object

.….….….….….….….….….….….….….….….….….….….….….….….….….….



37
38
39
# File 'lib/agent_xmpp/models/publication.rb', line 37

def update_status(node, status)
  publications.filter(:node => node).update(:status => status.to_s)
end