Class: ExtDirect::Request

Inherits:
Rack::Request
  • Object
show all
Defined in:
lib/ext_direct/request.rb

Instance Method Summary collapse

Constructor Details

#initialize(env) ⇒ Request

Returns a new instance of Request.



3
4
5
6
# File 'lib/ext_direct/request.rb', line 3

def initialize(env)
  update_env(env)
  super
end

Instance Method Details

#actionObject



8
9
10
# File 'lib/ext_direct/request.rb', line 8

def action
  params.fetch("extAction", params.fetch("action", "unknown"))
end

#dataObject



16
17
18
19
20
21
22
23
24
25
# File 'lib/ext_direct/request.rb', line 16

def data
  if type == :event
    event_params = params.dup
    event_params.delete("action")
    event_params.delete("method")
    event_params
  else
    params.fetch("data", [])
  end
end

#event?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/ext_direct/request.rb', line 41

def event?
  (type == :event)
end

#methodObject



12
13
14
# File 'lib/ext_direct/request.rb', line 12

def method
  params.fetch("extMethod", params.fetch("method", "unknown"))
end

#rpc?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/ext_direct/request.rb', line 45

def rpc?
  (type == :rpc)
end

#tidObject



27
28
29
# File 'lib/ext_direct/request.rb', line 27

def tid
  params.fetch("extTID", params.fetch("tid", 0))
end

#typeObject



31
32
33
34
35
36
37
38
39
# File 'lib/ext_direct/request.rb', line 31

def type
  if get?
    :event
  elsif post? and params.include? "type"
    params.fetch("type").to_sym
  else
    :unknown
  end
end

#upload?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/ext_direct/request.rb', line 49

def upload?
  params.include? "extUpload"
end