Module: Rum::Docker::Executable
Overview
Mixin to enable runtime Docker command manipulation.
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
The
OPTIONSportion of a Docker command.
Instance Method Summary collapse
-
#each ⇒ Object
Yield Docker command word by word.
-
#initialize(options: nil, &block) ⇒ Object
Initialize Docker executable with
OPTIONSand evaluate the&blockif given. -
#method_missing(m, *args, &block) ⇒ Object
Interpret missing methods as
OPTION. -
#to_s ⇒ Object
Convert Docker command to string.
-
#with_defaults(options = {}) ⇒ Object
Assign default values to Docker command if not explicitly set.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
Interpret missing methods as OPTION.
70 71 72 73 |
# File 'lib/rumrunner/docker.rb', line 70 def method_missing(m, *args, &block) .send(m, *args, &block) args.empty? ? [m] : self end |
Instance Attribute Details
#options ⇒ Object (readonly)
The OPTIONS portion of a Docker command.
51 52 53 |
# File 'lib/rumrunner/docker.rb', line 51 def end |
Instance Method Details
#each ⇒ Object
Yield Docker command word by word.
63 64 65 66 |
# File 'lib/rumrunner/docker.rb', line 63 def each self.class.name.split(/::/)[1..-1].each{|x| yield x.downcase } .each{|x| yield x } end |
#initialize(options: nil, &block) ⇒ Object
Initialize Docker executable with OPTIONS and evaluate the &block if given.
56 57 58 59 |
# File 'lib/rumrunner/docker.rb', line 56 def initialize(options:nil, &block) = || Options.new instance_eval(&block) if block_given? end |
#to_s ⇒ Object
Convert Docker command to string.
77 78 79 |
# File 'lib/rumrunner/docker.rb', line 77 def to_s to_a.join(" ") end |
#with_defaults(options = {}) ⇒ Object
Assign default values to Docker command if not explicitly set.
Example:
Run.new(&block).with_defaults(user: "fizz")
Unless the &block contains a directive to set a value for user, it will be set to “fizz”.
89 90 91 92 |
# File 'lib/rumrunner/docker.rb', line 89 def with_defaults( = {}) .reject{|k,v| .include? k }.each{|k,v| [k] << v } self end |