Class: Oksky::Chat::WhClient

Inherits:
Object
  • Object
show all
Defined in:
lib/oksky/chat/whclient.rb

Instance Method Summary collapse

Instance Method Details

#parse_events_from(request_body) ⇒ Array<Oksky::Chat::Event::Class>

Parse events from request.body

Parameters:

  • request_body (String)

Returns:

  • (Array<Oksky::Chat::Event::Class>)


10
11
12
13
14
15
16
17
18
19
# File 'lib/oksky/chat/whclient.rb', line 10

def parse_events_from(request_body)
  json = JSON.parse(request_body)

  begin
    klass = Oksky::Chat::Object.const_get("#{object_type(json['object_name']).capitalize}Resource")
    klass.new(json['object'])
  rescue NameError => e
    Oksky::Chat::Object::UnsupportResource.new(json['object'])
  end
end