lib/flapjack/data/notification_rule.rb in flapjack-0.7.1 vs lib/flapjack/data/notification_rule.rb in flapjack-0.7.2
- old
+ new
@@ -103,11 +103,11 @@
@critical_blackhole = ((rule_data['critical_blackhole'] || 'false').downcase == 'true')
end
def update(rule_data)
- self.class.add_or_update(rule_data, :redis => @redis)
+ self.class.add_or_update(rule_data.merge(:id => @id), :redis => @redis)
self.refresh
end
def to_json(*args)
hash = (Hash[ *([:id, :contact_id, :entity_tags, :entities,
@@ -152,9 +152,11 @@
raise "a redis connection must be supplied" unless @redis
@id = rule_data[:id]
end
def self.add_or_update(rule_data, options = {})
+ raise ":id is a required key in rule_data" unless rule_data[:id]
+
redis = options[:redis]
rule_data[:entities] = Yajl::Encoder.encode(rule_data[:entities])
rule_data[:entity_tags] = Yajl::Encoder.encode(rule_data[:entity_tags])
rule_data[:time_restrictions] = Yajl::Encoder.encode(rule_data[:time_restrictions])