Class: Castle::API::Session
- Inherits:
-
Object
- Object
- Castle::API::Session
- Includes:
- Singleton
- Defined in:
- lib/castle/api/session.rb
Overview
this class keeps http config object and provides start/finish methods for persistent connection usage when there is a need of sending multiple requests at once
Instance Attribute Summary collapse
-
#http ⇒ Object
Returns the value of attribute http.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Session
constructor
A new instance of Session.
- #reset ⇒ Object
Constructor Details
#initialize ⇒ Session
Returns a new instance of Session.
15 16 17 |
# File 'lib/castle/api/session.rb', line 15 def initialize reset end |
Instance Attribute Details
#http ⇒ Object
Returns the value of attribute http.
13 14 15 |
# File 'lib/castle/api/session.rb', line 13 def http @http end |
Class Method Details
.get ⇒ Net::HTTP
33 34 35 |
# File 'lib/castle/api/session.rb', line 33 def get instance.http end |
Instance Method Details
#reset ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/castle/api/session.rb', line 19 def reset @http = Net::HTTP.new(Castle.config.host, Castle.config.port) @http.read_timeout = Castle.config.request_timeout / 1000.0 if Castle.config.port == 443 @http.use_ssl = true @http.verify_mode = OpenSSL::SSL::VERIFY_PEER end @http end |