Class: CPEE::Notifications::Subscription

Inherits:
Riddl::Implementation
  • Object
show all
Defined in:
lib/cpee/implementation_notifications.rb

Overview

}}}

Instance Method Summary collapse

Instance Method Details

#responseObject

{{{



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/cpee/implementation_notifications.rb', line 72

def response
  id = @a[0]
  opts = @a[1]
  key = @r[-1]
  Riddl::Parameter::Complex.new("subscriptions","text/xml") do
    ret = XML::Smart::string "      <subscription xmlns='http://riddl.org/ns/common-patterns/notifications-producer/2.0'/>\n    END\n    url = CPEE::Persistence::extract_item(id,opts,File.join('handler',key,'url'))\n    ret.root.attributes['url'] = url if url && !url.empty?\n    items = {}\n    CPEE::Persistence::extract_handler(id,opts,key).each do |h|\n      t, i, v = h.split('/')\n      items[t] ||= []\n      items[t] << [i,v]\n    end\n    items.each do |k,v|\n      ret.root.add('topic').tap do |n|\n        n.attributes['id'] = k\n        v.each do |e|\n          n.add *e\n        end\n      end\n    end\n    ret.to_s\n  end\nend\n"