Class: Hash
- Inherits:
-
Object
show all
- Defined in:
- lib/fleck/utilities/hash_with_indifferent_access.rb
Overview
Open ‘Hash` class to add `#to_hash_with_indifferent_access` method and some filter features.
Instance Method Summary
collapse
Instance Method Details
#filter! ⇒ Object
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/fleck/utilities/hash_with_indifferent_access.rb', line 70
def filter!
filters = Fleck.config.filters
keys.each do |key|
if filters.include?(key.to_s)
self[key] = '[FILTERED]'
elsif self[key].is_a?(Hash)
self[key] = self[key].dup.filter!
end
end
self
end
|
#filtered! ⇒ Object
61
62
63
64
65
66
67
68
|
# File 'lib/fleck/utilities/hash_with_indifferent_access.rb', line 61
def filtered!
@filtered = true
keys.each do |key|
self[key].filtered! if self[key].is_a?(Hash)
end
self
end
|
#to_hash_with_indifferent_access ⇒ Object
#to_s ⇒ Object
55
56
57
58
59
|
# File 'lib/fleck/utilities/hash_with_indifferent_access.rb', line 55
def to_s
return dup.filter!.inspect if @filtered
super
end
|