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

Defined Under Namespace

Modules: Case Classes: Cache, CustomLimit, Error, Instrumentation, LazyLoader, LinkFollower, MergeCommit, NestedResources, Normalizer, Pagination, Parallel, Remote, Response, ResponseWrapper, 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.16.0'

Class Method Summary collapse

Class Method Details

.currentObject



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

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

.current=(backend) ⇒ Object



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

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



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

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

.set(options) ⇒ Object



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

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

.with(backend) ⇒ Object



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

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