class Praxis::Types::FuzzyHash
Public Class Methods
Source
# File lib/praxis/types/fuzzy_hash.rb, line 6 def initialize(value = {}) @hash = {} @regexes = [] update(value) end
Public Instance Methods
Source
# File lib/praxis/types/fuzzy_hash.rb, line 28 def [](key) return @hash[key] if @hash.key?(key) key = key.to_s @regexes.each do |regex| return @hash[regex] if regex.match(key) end nil end
Source
# File lib/praxis/types/fuzzy_hash.rb, line 20 def []=(key, val) case key when Regexp @regexes << key end @hash[key] = val end
Source
# File lib/praxis/types/fuzzy_hash.rb, line 39 def method_missing(*args, &block) @hash.send(*args, &block) end
Source
# File lib/praxis/types/fuzzy_hash.rb, line 43 def respond_to_missing?(*args) @hash.respond_to?(*args) end
Source
# File lib/praxis/types/fuzzy_hash.rb, line 12 def update(value) value.each do |key, val| self[key] = val end self end