Class: CPEE::Notifications::UpdateSubscription

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

Overview

}}}

Instance Method Summary collapse

Instance Method Details

#responseObject

{{{



149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# File 'lib/cpee/implementation_notifications.rb', line 149

def response
  id = @a[0]
  opts = @a[1]
  key = @r.last

  if opts[:statemachine].final? id
    @status = 410
  else
    if CPEE::Persistence::exists_handler?(id,opts,key)
      url = @p[0].name == 'url' ? @p.shift.value : nil
      values = []
      while @p.length > 0
        topic = @p.shift.value
        base = @p.shift
        type = base.name
        values += base.value.split(',').map { |i| File.join(topic,type[0..-2],i) }
      end
      @header = CPEE::Persistence::set_handler(id,opts,key,url,values,true)
    else
      @status = 404
    end
  end
end