2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/jbuilder_reopen/jbuilder_template.rb', line 2
def reopen!(keys=[], &block)
keys = keys.dup
if keys.empty?
_scope(@attributes) { yield @attributes }
else
return if _blank?
key = keys.shift
result = if ::Array === @attributes[key]
@attributes[key].map do |element|
_scope(element) { reopen!(keys, &block) }
end
elsif ::Hash === @attributes[key]
_scope(@attributes[key]) { reopen!(keys, &block) }
end
@attributes[key] = result if result.present?
@attributes
end
end
|