Class: Kamaze::DockerImage::Loader
- Inherits:
-
Object
- Object
- Kamaze::DockerImage::Loader
- Defined in:
- lib/kamaze/docker_image/loader.rb
Overview
Loader for tasks (using eval binding)
Defined Under Namespace
Modules: Context Classes: Helper
Instance Attribute Summary collapse
- #image ⇒ Kamaze::DockerImage readonly protected
Instance Method Summary collapse
-
#call ⇒ self
Load tasks.
-
#content ⇒ String
protected
Tasks file content (to eval).
- #context ⇒ Module<Context> protected
- #file ⇒ Pathname protected
-
#initialize(image) ⇒ Loader
constructor
A new instance of Loader.
- #loadable? ⇒ Boolean
Constructor Details
#initialize(image) ⇒ Loader
Returns a new instance of Loader.
17 18 19 |
# File 'lib/kamaze/docker_image/loader.rb', line 17 def initialize(image) @image = image.clone.freeze end |
Instance Attribute Details
#image ⇒ Kamaze::DockerImage (readonly, protected)
43 44 45 |
# File 'lib/kamaze/docker_image/loader.rb', line 43 def image @image end |
Instance Method Details
#call ⇒ self
Load tasks.
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/kamaze/docker_image/loader.rb', line 24 def call self.tap do if loadable? context.call do |b| b.local_variable_set(:image, image) b.eval(content) end end end end |
#content ⇒ String (protected)
Tasks file content (to eval)
53 54 55 |
# File 'lib/kamaze/docker_image/loader.rb', line 53 def content file.read end |
#context ⇒ Module<Context> (protected)
58 59 60 |
# File 'lib/kamaze/docker_image/loader.rb', line 58 def context Context end |
#file ⇒ Pathname (protected)
46 47 48 |
# File 'lib/kamaze/docker_image/loader.rb', line 46 def file Pathname.new(__dir__).join('loader', 'tasks.rb') end |
#loadable? ⇒ Boolean
36 37 38 |
# File 'lib/kamaze/docker_image/loader.rb', line 36 def loadable? context.dsl? end |