Module: Travis::Client::Context
- Included in:
- Travis
- Defined in:
- lib/travis/client/context.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#default_endpoint ⇒ Object
Returns the value of attribute default_endpoint.
-
#session ⇒ Object
readonly
Returns the value of attribute session.
Instance Method Summary collapse
- #after_request(&block) ⇒ Object
- #before_request(&block) ⇒ Object
- #clear_cache ⇒ Object
- #connect(**options) ⇒ Object
- #connected? ⇒ Boolean
- #const_missing(const) ⇒ Object
- #new(**options) ⇒ Object
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
8 9 10 |
# File 'lib/travis/client/context.rb', line 8 def connection @connection end |
#default_endpoint ⇒ Object
Returns the value of attribute default_endpoint.
7 8 9 |
# File 'lib/travis/client/context.rb', line 7 def default_endpoint @default_endpoint end |
#session ⇒ Object (readonly)
Returns the value of attribute session.
8 9 10 |
# File 'lib/travis/client/context.rb', line 8 def session @session end |
Instance Method Details
#after_request(&block) ⇒ Object
41 42 43 |
# File 'lib/travis/client/context.rb', line 41 def after_request(&block) connection.after_request(&block) end |
#before_request(&block) ⇒ Object
37 38 39 |
# File 'lib/travis/client/context.rb', line 37 def before_request(&block) connection.before_request(&block) end |
#clear_cache ⇒ Object
32 33 34 35 |
# File 'lib/travis/client/context.rb', line 32 def clear_cache return unless connected? session.response_cache.clear end |
#connect(**options) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/travis/client/context.rb', line 10 def connect(**) @call_site ||= caller.first if connected? and not defined? @warned line = @call_site == caller.first ? @call_site : "#{@call_site} and #{caller.first}" $stderr.puts(WARNING % [self, line]) @warned = true end @connection = new(**) @session = @connection.create_session @session.define_constants(self) @session end |
#connected? ⇒ Boolean
28 29 30 |
# File 'lib/travis/client/context.rb', line 28 def connected? !session.nil? end |
#const_missing(const) ⇒ Object
45 46 47 48 49 50 |
# File 'lib/travis/client/context.rb', line 45 def const_missing(const) super rescue NameError => error = connected? ? error. : "#{error.}, try running #{self.inspect}.connect" raise error, , caller(2) end |
#new(**options) ⇒ Object
24 25 26 |
# File 'lib/travis/client/context.rb', line 24 def new(**) Connection.new(**) end |