Top Level Namespace
Defined Under Namespace
Modules: LucidHttp
Instance Method Summary collapse
- #__lucid_http__clean ⇒ Object
- #__lucid_http__get_body ⇒ Object
- #__lucid_http__setup(url, action: :get, follow: false, form: nil, json: false, **opts) ⇒ Object
- #body ⇒ Object
- #content_type ⇒ Object
- #error ⇒ Object
- #path ⇒ Object
- #response ⇒ Object
- #status ⇒ Object
Instance Method Details
#__lucid_http__clean ⇒ Object
26 27 28 29 30 |
# File 'lib/lucid_http.rb', line 26 def __lucid_http__clean instance_variables.grep(/@__lucid_http__/).each do |v| remove_instance_variable(v.to_sym) end end |
#__lucid_http__get_body ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/lucid_http.rb', line 47 def __lucid_http__get_body original_body = response.body.to_s if !@__lucid_http__json original_body else JSON.parse(original_body) end end |
#__lucid_http__setup(url, action: :get, follow: false, form: nil, json: false, **opts) ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/lucid_http.rb', line 32 def __lucid_http__setup(url, action: :get, follow: false, form: nil, json: false, **opts) __lucid_http__clean @__lucid_http__client = HTTP.persistent(LucidHttp.target_url) if follow @__lucid_http__client = @__lucid_http__client.follow end @__lucid_http__path = @__lucid_http__client..persistent + url @__lucid_http__res = @__lucid_http__client.send(action.to_sym, url, form: form) @__lucid_http__json = json end |
#body ⇒ Object
43 44 45 |
# File 'lib/lucid_http.rb', line 43 def body @__lucid_http__body ||= __lucid_http__get_body end |
#content_type ⇒ Object
60 61 62 |
# File 'lib/lucid_http.rb', line 60 def content_type response.content_type.mime_type end |
#error ⇒ Object
68 69 70 71 72 73 74 |
# File 'lib/lucid_http.rb', line 68 def error if status.to_i == 500 body.split("\n").first else "No 500 error found." end end |
#path ⇒ Object
64 65 66 |
# File 'lib/lucid_http.rb', line 64 def path @__lucid_http__path end |
#response ⇒ Object
22 23 24 |
# File 'lib/lucid_http.rb', line 22 def response @__lucid_http__res end |
#status ⇒ Object
56 57 58 |
# File 'lib/lucid_http.rb', line 56 def status @__lucid_http__status = LucidHttp::PrettyStatus.new(response.status) end |