Class: Atatus::Config::WildcardPatternList Private

Inherits:
Object
  • Object
show all
Defined in:
lib/atatus/config/wildcard_pattern_list.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Defined Under Namespace

Classes: WildcardPattern

Instance Method Summary collapse

Instance Method Details

#call(value) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/atatus/config/wildcard_pattern_list.rb', line 66

def call(value)
  hash = false
  if value.is_a?(Hash)
    hash = true
  elsif value.is_a?(String)
    value = value.split(',')
  else
    value = Array(value)
  end          

  if !hash 
    value = value.map do |p|
      if p.is_a?(WildcardPattern) 
        p
      else
        begin
          WildcardPattern.new(p)
        rescue RegexpError
          nil
        end
      end
    end

  else
    new_hash = {}
    value = value.map do |k, v|
      new_hash[WildcardPattern.new(k)] = v
    end
    value = new_hash
  end

  value.uniq.compact
end