lib/hawkular/hawkular_client.rb in hawkular-client-3.0.2 vs lib/hawkular/hawkular_client.rb in hawkular-client-4.0.0
- old
+ new
@@ -10,11 +10,13 @@
attr_reader :inventory, :metrics, :alerts, :operations, :tokens, :state
def initialize(hash)
hash[:credentials] ||= {}
hash[:options] ||= {}
- fail 'no parameter ":entrypoint" given' if hash[:entrypoint].nil?
+
+ fail Hawkular::ArgumentError, 'no parameter ":entrypoint" given' if hash[:entrypoint].nil?
+
@state = hash
end
def method_missing(name, *args, &block)
delegate_client = case name
@@ -22,10 +24,10 @@
when /^metrics_/ then metrics
when /^alerts_/ then alerts
when /^operations_/ then operations
when /^tokens_/ then tokens
else
- fail "unknown method prefix `#{name}`, allowed prefixes:"\
+ fail Hawkular::ArgumentError, "unknown method prefix `#{name}`, allowed prefixes:"\
'`inventory_`, `metrics_`,`alerts_`,`operations_`, `tokens_`'
end
method = name.to_s.sub(/^[^_]+_/, '')
delegate_client.__send__(method, *args, &block)
end