Class: Sysdig::AlertFilter
- Inherits:
-
Object
- Object
- Sysdig::AlertFilter
- Defined in:
- lib/sysdig/alert_filter.rb
Class Method Summary collapse
Class Method Details
.dump(hash) ⇒ Object
2 3 4 |
# File 'lib/sysdig/alert_filter.rb', line 2 def self.dump(hash) hash.map { |k,v| [k, normalize_condition(v).inspect].join(" = ") }.join(", ") end |
.load(hash_or_string) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/sysdig/alert_filter.rb', line 6 def self.load(hash_or_string) case hash_or_string when NilClass, Hash hash_or_string when String hash_or_string.split(", ").map { |t| t.split(" = ") }.inject({}) { |r,(k,c)| r.merge(k => normalize_condition(c)) } else nil end end |
.normalize_condition(string) ⇒ Object
18 19 20 |
# File 'lib/sysdig/alert_filter.rb', line 18 def self.normalize_condition(string) string.gsub(/(^\\?['"])|(\\?['"]$)/, "") end |