Files
canine/app/helpers/dot_settable.rb
2024-12-25 21:30:59 -08:00

9 lines
225 B
Ruby

module DotSettable
def dotset(path, value)
keys = path.split(".")
last_key = keys.pop
nested_hash = keys.inject(self) { |current_hash, key| current_hash[key] ||= {} }
nested_hash[last_key] = value
end
end