Class: CPEE::Callbacks::ExCallback

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

Overview

}}}

Instance Method Summary collapse

Instance Method Details

#responseObject

{{{



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/cpee/implementation_callbacks.rb', line 111

def response
  id = @a[0]
  opts = @a[1]
  callback = @r[-1]

  if CPEE::Persistence::extract_item(id,opts,"callback/#{callback}/type") == 'callback'
    ret = {}
    ret['values'] = @p.map{ |e|
      [e.name, e.class == Riddl::Parameter::Simple ? [:simple,e.value] : [:complex,e.mimetype,e.value.path] ]
    }
    ret['headers'] =  @h

    CPEE::Message::send(
      :'callback-response',
      callback,
      opts[:url],
      id,
      {},
      {},
      ret,
      opts[:redis]
    )
  elsif CPEE::Persistence::extract_item(id,opts,"callback/#{callback}/type") == 'vote'
    if @p.length == 1 && @p[0].name == 'continue' && @p[0].class == Riddl::Parameter::Simple
      CPEE::Message::send(
        :'vote-response',
        callback,
        opts[:url],
        id,
        {},
        {},
        @p[0].value,
        opts[:redis]
      )
    else
      @status = 400
    end
  else
    @status = 503
  end
  nil
end