Use key? instead of has_key?

This commit is contained in:
Pawel Chojnacki 2017-06-07 12:41:06 +02:00
parent dbb3c28088
commit 6eb96b2019
2 changed files with 3 additions and 3 deletions

View file

@ -14,14 +14,14 @@ module Gitlab
end
def metric_from_entry(entry)
missing_fields = [:title, :required_metrics, :weight, :queries].select { |key| !entry.has_key?(key) }
missing_fields = [:title, :required_metrics, :weight, :queries].select { |key| !entry.key?(key) }
raise ParsingError.new("entry missing required fields #{missing_fields}") unless missing_fields.empty?
Metric.new(entry[:title], entry[:required_metrics], entry[:weight], entry[:y_label], entry[:queries])
end
def group_from_entry(entry)
missing_fields = [:group, :priority, :metrics].select { |key| !entry.has_key?(key) }
missing_fields = [:group, :priority, :metrics].select { |key| !entry.key?(key) }
raise ParsingError.new("entry missing required fields #{missing_fields}") unless missing_fields.empty?
group = MetricGroup.new(entry[:group], entry[:priority])

View file

@ -44,7 +44,7 @@ module Gitlab
def process_query(context, query)
query_with_result = query.dup
query_with_result[:result] =
if query.has_key?(:query_range)
if query.key?(:query_range)
client_query_range(query[:query_range] % context, start: context[:timeframe_start], stop: context[:timeframe_end])
else
client_query(query[:query] % context, time: context[:timeframe_end])