Sha256: a20d302cdcc029a32738ecffe272b05949ec9dd7fa263b070ff1af41e77accf1
Contents?: true
Size: 900 Bytes
Versions: 1
Compression:
Stored size: 900 Bytes
Contents
class KuberKit::Core::ContextHelper::ContextArgs attr_reader :parent, :parent_name def initialize(context_args, parent_name = nil, parent = nil) @context_args = context_args @parent_name = parent_name @parent = parent end def method_missing(name, *args) if args.size > 0 raise ArgumentError.new("context args does not accept any arguments") end value = @context_args.fetch(name) do raise(KuberKit::Error, "build arg '#{format_arg(name)}' is not defined, available args: #{@context_args.inspect}") end if value.is_a?(Hash) return self.class.new(value, name, self) end value end private def format_arg(name) string = [@parent_name, name].compact.join(".") parent = @parent while parent do string = [parent.parent_name, string].compact.join(".") parent = parent.parent end string end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
kuber_kit-0.2.8 | lib/kuber_kit/core/context_helper/context_args.rb |