class Praxis::Types::FuzzyHash
Public Class Methods
new(value={})
click to toggle source
# File lib/praxis/types/fuzzy_hash.rb, line 5 def initialize(value={}) @hash = {} @regexes = [] update(value) end
Public Instance Methods
[](k)
click to toggle source
# File lib/praxis/types/fuzzy_hash.rb, line 27 def [](k) return @hash[k] if @hash.key?(k) k = k.to_s @regexes.each do |regex| return @hash[regex] if regex.match(k) end nil end
[]=(k,v)
click to toggle source
# File lib/praxis/types/fuzzy_hash.rb, line 19 def []=(k,v) case k when Regexp @regexes << k end @hash[k] = v end
method_missing(*args, &block)
click to toggle source
# File lib/praxis/types/fuzzy_hash.rb, line 38 def method_missing(*args, &block) @hash.send(*args, &block) end
respond_to_missing?(*args)
click to toggle source
# File lib/praxis/types/fuzzy_hash.rb, line 42 def respond_to_missing?(*args) @hash.respond_to?(*args) end
update(value)
click to toggle source
# File lib/praxis/types/fuzzy_hash.rb, line 11 def update(value) value.each do |k,v| self[k] = v end self end