class Absinthe::Plugins::Context

Public Class Methods

new(injector) click to toggle source
# File lib/absinthe/plugins/context.rb, line 8
def initialize injector
  @injector = injector
  @run_blocks = []
  self[:namespace].register :context, self
  instance_exec(&self[:boot_proc]) if self[:boot_proc]
end
register(injector) click to toggle source
# File lib/absinthe/plugins/context.rb, line 4
def self.register injector
  injector.register :context, Context, :injector
end

Public Instance Methods

[](name) click to toggle source
# File lib/absinthe/plugins/context.rb, line 31
def [] name
  inject name
end
boot!() click to toggle source
# File lib/absinthe/plugins/context.rb, line 46
def boot!
  boot_scope = (self[:calling_context] || self[:main_object])
  @run_blocks.each do |run|
    injections = run[:args].map(&method(:inject))
    boot_scope.instance_exec(*injections, &run[:block])
  end
end
configure(&block) click to toggle source
# File lib/absinthe/plugins/context.rb, line 15
def configure &block
  self.instance_eval &block
end
const(name, value) click to toggle source
# File lib/absinthe/plugins/context.rb, line 19
def const name, value
  @injector.register name, value
end
inject(name) click to toggle source
# File lib/absinthe/plugins/context.rb, line 27
def inject name
  @injector.inject name
end
plugin!(name) click to toggle source
# File lib/absinthe/plugins/context.rb, line 35
def plugin! name
  self[:plugin].load name
end
register(name, clazz, *args) click to toggle source
# File lib/absinthe/plugins/context.rb, line 23
def register name, clazz, *args
  @injector.register name, clazz, *args
end
run(*args, &block) click to toggle source
# File lib/absinthe/plugins/context.rb, line 39
def run *args, &block
  @run_blocks << {
    :args => args,
    :block => block
  }
end