Class: VkMusic::Request::Base
- Inherits:
-
Object
- Object
- VkMusic::Request::Base
show all
- Extended by:
- Forwardable
- Defined in:
- lib/vk_music/request/base.rb
Overview
Base class for most of requests
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(path, data = {}, method = 'GET', headers = {}) ⇒ Base
25
26
27
28
29
30
31
32
|
# File 'lib/vk_music/request/base.rb', line 25
def initialize(path, data = {}, method = 'GET', = {})
@path = path
@data = data
@method = method.upcase
@headers =
@response = nil
end
|
Instance Attribute Details
#data ⇒ Hash
12
13
14
|
# File 'lib/vk_music/request/base.rb', line 12
def data
@data
end
|
16
17
18
|
# File 'lib/vk_music/request/base.rb', line 16
def
@headers
end
|
#method ⇒ String
14
15
16
|
# File 'lib/vk_music/request/base.rb', line 14
def method
@method
end
|
#path ⇒ String
10
11
12
|
# File 'lib/vk_music/request/base.rb', line 10
def path
@path
end
|
#response ⇒ Mechanize::File?
18
19
20
|
# File 'lib/vk_music/request/base.rb', line 18
def response
@response
end
|
Instance Method Details
#call(agent) ⇒ self
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/vk_music/request/base.rb', line 36
def call(agent)
before_call
log
@response = case method
when 'GET' then get(agent)
when 'POST' then post(agent)
else raise(ArgumentError, "unsupported method #{method}")
end
after_call
self
end
|