Class: AgentXmpp::ServicesModel
- Inherits:
-
Object
- Object
- AgentXmpp::ServicesModel
- Defined in:
- lib/agent_xmpp/client/services_model.rb
Overview
Instance Method Summary collapse
-
#create(jid) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
#features(jid, node = nil) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
#find_all_by_category(cat) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
#find_all_by_category_and_type(cat) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
#has_feature?(jid, feature) ⇒ Boolean
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
#has_item?(jid, ijid) ⇒ Boolean
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
#has_jid?(jid) ⇒ Boolean
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
#identities(jid, node = nil) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
#initialize ⇒ ServicesModel
constructor
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
#items(jid, node = nil) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
#method_missing(meth, *args, &blk) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
#update_with_discoinfo(disco) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
#update_with_discoitems(disco) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
Constructor Details
#initialize ⇒ ServicesModel
.….….….….….….….….….….….….….….….….….….….….….….….….….….
8 9 10 |
# File 'lib/agent_xmpp/client/services_model.rb', line 8 def initialize @service = Hash.new{|hash, key| hash[key] = {}} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &blk) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
74 75 76 |
# File 'lib/agent_xmpp/client/services_model.rb', line 74 def method_missing(meth, *args, &blk) @service.send(meth, *args, &blk) end |
Instance Method Details
#create(jid) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
23 24 25 |
# File 'lib/agent_xmpp/client/services_model.rb', line 23 def create(jid) @service[jid.to_s] = {} end |
#features(jid, node = nil) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
50 51 52 53 54 |
# File 'lib/agent_xmpp/client/services_model.rb', line 50 def features(jid, node=nil) if has_jid?(jid.to_s) node.nil ? @service[from_jid][:discoinfo].features : @service[from_jid][:node][node][:discoinfo].features else; []; end end |
#find_all_by_category(cat) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
13 14 15 |
# File 'lib/agent_xmpp/client/services_model.rb', line 13 def find_all_by_category(cat) @service.select{|(k,v)| not v[:discoinfo].identities.select{|i| i.category.eql?(cat)}.empty?} end |
#find_all_by_category_and_type(cat) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
18 19 20 |
# File 'lib/agent_xmpp/client/services_model.rb', line 18 def find_all_by_category_and_type(cat) @service.select{|(k,v)| not v[:discoinfo].identities.select{|i| i.category.eql?(cat) and i.type.eql?(type)}.empty?} end |
#has_feature?(jid, feature) ⇒ Boolean
.….….….….….….….….….….….….….….….….….….….….….….….….….….
33 34 35 |
# File 'lib/agent_xmpp/client/services_model.rb', line 33 def has_feature?(jid, feature) not features(jid.to_s).select{|f| f.var.eql?(feature)}.empty? end |
#has_item?(jid, ijid) ⇒ Boolean
.….….….….….….….….….….….….….….….….….….….….….….….….….….
38 39 40 |
# File 'lib/agent_xmpp/client/services_model.rb', line 38 def has_item?(jid, ijid) not items(jid.to_s).select{|i| i.jid.eql?(i.jid)}.empty? end |
#has_jid?(jid) ⇒ Boolean
.….….….….….….….….….….….….….….….….….….….….….….….….….….
28 29 30 |
# File 'lib/agent_xmpp/client/services_model.rb', line 28 def has_jid?(jid) @service.has_key?(jid.to_s) end |
#identities(jid, node = nil) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
43 44 45 46 47 |
# File 'lib/agent_xmpp/client/services_model.rb', line 43 def identities(jid, node=nil) if has_jid?(jid.to_s) node.nil ? @service[from_jid][:discoinfo].identities : @service[from_jid][:node][node][:discoinfo].identities else; []; end end |
#items(jid, node = nil) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
57 58 59 60 61 |
# File 'lib/agent_xmpp/client/services_model.rb', line 57 def items(jid, node=nil) if has_jid?(jid.to_s) node.nil ? @service[from_jid][:discoitems].items : @service[from_jid][:node][node][:discoitems].items else; []; end end |
#update_with_discoinfo(disco) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
64 65 66 |
# File 'lib/agent_xmpp/client/services_model.rb', line 64 def update_with_discoinfo(disco) save_item_disco(:discoinfo, disco) end |
#update_with_discoitems(disco) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
69 70 71 |
# File 'lib/agent_xmpp/client/services_model.rb', line 69 def update_with_discoitems(disco) save_item_disco(:discoitems, disco) end |