Class: DoneDone::Http
- Inherits:
-
Object
- Object
- DoneDone::Http
- Defined in:
- lib/donedone/http.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#files ⇒ Object
readonly
Returns the value of attribute files.
-
#get_class ⇒ Object
readonly
Returns the value of attribute get_class.
-
#http_class ⇒ Object
readonly
Returns the value of attribute http_class.
-
#method_url ⇒ Object
readonly
Returns the value of attribute method_url.
-
#multipart_post_class ⇒ Object
readonly
Returns the value of attribute multipart_post_class.
-
#post_class ⇒ Object
readonly
Returns the value of attribute post_class.
-
#put_class ⇒ Object
readonly
Returns the value of attribute put_class.
-
#ssl_verify_mode ⇒ Object
readonly
Returns the value of attribute ssl_verify_mode.
-
#ssl_version ⇒ Object
readonly
Returns the value of attribute ssl_version.
Instance Method Summary collapse
- #get(method_url, options = {}) ⇒ Object
- #host ⇒ Object
-
#initialize(domain, username, password, options = {}) ⇒ Http
constructor
A new instance of Http.
- #post(method_url, options = {}) ⇒ Object
- #put(method_url, options = {}) ⇒ Object
- #reset(options = {}) ⇒ Object
Constructor Details
#initialize(domain, username, password, options = {}) ⇒ Http
Returns a new instance of Http.
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/donedone/http.rb', line 14 def initialize(domain, username, password, ={}) @domain = domain @_username = username @_password = password @put_class = [:put_class] || Net::HTTP::Put @get_class = [:get_class] || Net::HTTP::Get @post_class = [:post_class] || Net::HTTP::Post @multipart_post_class = [:multipart_post_class] || Multipart::Post @http_class = [:http_class] || Net::HTTP @ssl_verify_mode = [:ssl_verify_mode] || Constant::SSL_VERIFY_MODE @ssl_version = [:ssl_version] || Constant::SSL_VERSION end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
7 8 9 |
# File 'lib/donedone/http.rb', line 7 def data @data end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
7 8 9 |
# File 'lib/donedone/http.rb', line 7 def domain @domain end |
#files ⇒ Object (readonly)
Returns the value of attribute files.
7 8 9 |
# File 'lib/donedone/http.rb', line 7 def files @files end |
#get_class ⇒ Object (readonly)
Returns the value of attribute get_class.
12 13 14 |
# File 'lib/donedone/http.rb', line 12 def get_class @get_class end |
#http_class ⇒ Object (readonly)
Returns the value of attribute http_class.
13 14 15 |
# File 'lib/donedone/http.rb', line 13 def http_class @http_class end |
#method_url ⇒ Object (readonly)
Returns the value of attribute method_url.
7 8 9 |
# File 'lib/donedone/http.rb', line 7 def method_url @method_url end |
#multipart_post_class ⇒ Object (readonly)
Returns the value of attribute multipart_post_class.
12 13 14 |
# File 'lib/donedone/http.rb', line 12 def multipart_post_class @multipart_post_class end |
#post_class ⇒ Object (readonly)
Returns the value of attribute post_class.
12 13 14 |
# File 'lib/donedone/http.rb', line 12 def post_class @post_class end |
#put_class ⇒ Object (readonly)
Returns the value of attribute put_class.
12 13 14 |
# File 'lib/donedone/http.rb', line 12 def put_class @put_class end |
#ssl_verify_mode ⇒ Object (readonly)
Returns the value of attribute ssl_verify_mode.
13 14 15 |
# File 'lib/donedone/http.rb', line 13 def ssl_verify_mode @ssl_verify_mode end |
#ssl_version ⇒ Object (readonly)
Returns the value of attribute ssl_version.
13 14 15 |
# File 'lib/donedone/http.rb', line 13 def ssl_version @ssl_version end |
Instance Method Details
#get(method_url, options = {}) ⇒ Object
46 47 48 49 50 |
# File 'lib/donedone/http.rb', line 46 def get(method_url, ={}) @method_url = method_url reset() request(get_class) end |
#host ⇒ Object
39 40 41 42 43 44 |
# File 'lib/donedone/http.rb', line 39 def host unless @host @host = Constant.url_for('HOST', domain) end @host end |
#post(method_url, options = {}) ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/donedone/http.rb', line 60 def post(method_url, ={}) @method_url = method_url reset() request(post_class) do files ? append_multipart_data : append_any_form_data end end |
#put(method_url, options = {}) ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/donedone/http.rb', line 52 def put(method_url, ={}) @method_url = method_url reset() request(put_class) do append_any_form_data end end |
#reset(options = {}) ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/donedone/http.rb', line 28 def reset( = {}) @data = [:data] @files = [:files] @_request = nil @uri = nil @base_url = nil @host = nil @http = nil @_debug = .has_key?(:debug) ? [:debug] : false end |