lib/leap_cli/config/object.rb in leap_cli-1.5.1 vs lib/leap_cli/config/object.rb in leap_cli-1.5.6

- old
+ new

@@ -1,5 +1,7 @@ +# encoding: utf-8 + require 'erb' require 'json/pure' # pure ruby implementation is required for our sorted trick to work. if $ruby_version < [1,9] $KCODE = 'UTF8' @@ -94,20 +96,20 @@ # (2) support for nested references in a single string (e.g. ['a.b'] is the same as ['a']['b']) # the dot path is always absolute, starting at the top-most object. # def get!(key) key = key.to_s - if key =~ /\./ + if self.has_key?(key) + fetch_value(key) + elsif key =~ /\./ # for keys with with '.' in them, we start from the root object (@node). keys = key.split('.') value = @node.get!(keys.first) if value.is_a? Config::Object value.get!(keys[1..-1].join('.')) else value end - elsif self.has_key?(key) - fetch_value(key) else raise NoMethodError.new(key, "No method '#{key}' for #{self.class}") end end \ No newline at end of file