Module: Excom::Plugins::Context

Defined in:
lib/excom/plugins/context.rb

Defined Under Namespace

Modules: ExcomMethods

Instance Method Summary collapse

Instance Method Details

#contextObject



15
16
17
18
19
20
# File 'lib/excom/plugins/context.rb', line 15

def context
  global_context = ::Excom.context
  global_context.respond_to?(:merge) ?
    global_context.merge(local_context) :
    local_context
end

#initializeObject



5
6
7
8
# File 'lib/excom/plugins/context.rb', line 5

def initialize(*)
  @local_context = {}
  super
end

#initialize_cloneObject



10
11
12
13
# File 'lib/excom/plugins/context.rb', line 10

def initialize_clone(*)
  @local_context = @local_context.dup
  super
end

#with_context(ctx) ⇒ Object



22
23
24
# File 'lib/excom/plugins/context.rb', line 22

def with_context(ctx)
  clone.tap{ |copy| copy.local_context.merge!(ctx) }
end