]> gitweb.fluxo.info Git - leap/leap_cli.git/commitdiff
allow json properties to be named 'key'
authorelijah <elijah@riseup.net>
Fri, 31 Oct 2014 07:00:04 +0000 (00:00 -0700)
committerelijah <elijah@riseup.net>
Fri, 31 Oct 2014 07:00:04 +0000 (00:00 -0700)
lib/leap_cli/config/object.rb

index 489b1d2f2c58c685509e216cdbb4e7c39c4005b4..45144bcdd60860b6bf6c2e78a87ffa632702bdda 100644 (file)
@@ -64,6 +64,11 @@ module LeapCli
         get(key)
       end
 
+      # Overrride some default methods in Hash that are likely to
+      # be used as attributes.
+      alias_method :hkey, :key
+      def key; get('key'); end
+
       #
       # make hash addressable like an object (e.g. obj['name'] available as obj.name)
       #
@@ -288,23 +293,23 @@ module LeapCli
             Util::log "offending string: #{value}", :indent => 1
             Util::log "error message: no file '#{exc}'", :indent => 1
           end
+          raise exc if LeapCli.log_level >= 2
         end
-        raise exc if LeapCli.log_level >= 2
       rescue AssertionFailed => exc
         Util.bail! do
           Util::log :failed, "assertion while evaluating node '#{self.name}'"
           Util::log 'assertion: %s' % exc.assertion, :indent => 1
           Util::log "offending key: #{key}", :indent => 1
+          raise exc if LeapCli.log_level >= 2
         end
-        raise exc if LeapCli.log_level >= 2
       rescue SyntaxError, StandardError => exc
         Util::bail! do
           Util::log :error, "while evaluating node '#{self.name}'"
           Util::log "offending key: #{key}", :indent => 1
           Util::log "offending string: #{value}", :indent => 1
           Util::log "error message: #{exc.inspect}", :indent => 1
+          raise exc if LeapCli.log_level >= 2
         end
-        raise exc if LeapCli.log_level >= 2
       end
 
       private