Module: Kamaze::DockerImage::Loader::Context

Defined in:
lib/kamaze/docker_image/loader/context.rb

Overview

Provides empty binding.

Sample of use:

Context.call do |b|
  b.local_variable_set(:answer, 42)
  b.local_variable_set(:home, '127.0.0.1')

  b.eval(content)
end

Class Method Summary collapse

Class Method Details

.bindingBinding (protected)

Returns:

  • (Binding)


39
40
41
# File 'lib/kamaze/docker_image/loader/context.rb', line 39

def binding
  -> { super }.tap { load_dsl }.call
end

.call {|binding| ... } ⇒ Object

Yields:



25
26
27
# File 'lib/kamaze/docker_image/loader/context.rb', line 25

def call
  yield(binding)
end

.dslRake::DSL? (protected)

Returns:

  • (Rake::DSL, nil)


44
45
46
47
48
# File 'lib/kamaze/docker_image/loader/context.rb', line 44

def dsl
  Object.const_get('Rake::DSL')
rescue NameError
  nil
end

.dsl?Boolean

Denote DSL is defined.

Returns:

  • (Boolean)


32
33
34
# File 'lib/kamaze/docker_image/loader/context.rb', line 32

def dsl?
  !!dsl
end

.load_dslself (protected)

Apply Rake::DSL

Returns:

  • (self)


53
54
55
# File 'lib/kamaze/docker_image/loader/context.rb', line 53

def load_dsl
  self.tap { self.extend(dsl) if dsl? }
end