Module: GH

Extended by:
SingleForwardable
Defined in:
lib/gh.rb,
lib/gh/case.rb,
lib/gh/cache.rb,
lib/gh/error.rb,
lib/gh/stack.rb,
lib/gh/remote.rb,
lib/gh/version.rb,
lib/gh/wrapper.rb,
lib/gh/parallel.rb,
lib/gh/response.rb,
lib/gh/normalizer.rb,
lib/gh/pagination.rb,
lib/gh/lazy_loader.rb,
lib/gh/token_check.rb,
lib/gh/custom_limit.rb,
lib/gh/merge_commit.rb,
lib/gh/link_follower.rb,
lib/gh/instrumentation.rb,
lib/gh/nested_resources.rb,
lib/gh/response_wrapper.rb,
lib/gh/response_x_header_formatter.rb

Defined Under Namespace

Modules: Case Classes: Cache, CustomLimit, Error, Instrumentation, LazyLoader, LinkFollower, MergeCommit, NestedResources, Normalizer, Pagination, Parallel, Remote, Response, ResponseWrapper, ResponseXHeaderFormatter, Stack, TokenCheck, TokenInvalid, Wrapper

Constant Summary collapse

DefaultStack =
Stack.new do
  use Instrumentation
  use Parallel
  use TokenCheck
  use Pagination
  use LinkFollower
  use MergeCommit
  use LazyLoader
  use Normalizer
  use CustomLimit
  use Remote
end
VERSION =

Public: Library version.

'0.18.0'

Class Method Summary collapse

Class Method Details

.currentObject



48
49
50
# File 'lib/gh.rb', line 48

def self.current
  Thread.current[:GH] ||= DefaultStack.new
end

.current=(backend) ⇒ Object



52
53
54
# File 'lib/gh.rb', line 52

def self.current=(backend)
  Thread.current[:GH] = backend
end

.Error(conditions) ⇒ Object



56
57
58
59
60
61
62
63
# File 'lib/gh/error.rb', line 56

def self.Error(conditions)
  Module.new do
    define_singleton_method(:===) do |exception|
      return false unless Error === exception and not exception.info.nil?
      conditions.all? { |k,v| v === exception.info[k]}
    end
  end
end

.method_missing(*args, &block) ⇒ Object



59
60
61
# File 'lib/gh.rb', line 59

def self.method_missing(*args, &block)
  current.public_send(*args, &block)
end

.set(options) ⇒ Object



43
44
45
46
# File 'lib/gh.rb', line 43

def self.set(options)
  Thread.current[:GH] = nil
  DefaultStack.options.merge! options
end

.with(backend) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/gh.rb', line 25

def self.with(backend)
  if Hash === backend
    @options ||= {}
    @options, options = @options.merge(backend), @options
    backend = DefaultStack.build(@options)
  end

  if block_given?
    was, self.current = current, backend
    yield
  else
    backend
  end
ensure
  @options = options if options
  self.current = was if was
end