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

{{{



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/cpee/implementation_notifications.rb', line 91

def response
  id = @a[0]
  opts = @a[1]
  key = @r[-1]
  if CPEE::Persistence::exists_handler?(id,opts,key)
    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('handlers',key,'url'))\n      ret.root.attributes['id'] = key\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\n  else\n    @status = 404\n end\nend\n"